Patchwork [v3] libstdc++/52119

login
register
mail settings
Submitter Paolo Carlini
Date Feb. 5, 2012, 11:21 a.m.
Message ID <4F2E662E.7080303@oracle.com>
Download mbox | patch
Permalink /patch/139625/
State New
Headers show

Comments

Paolo Carlini - Feb. 5, 2012, 11:21 a.m.
Hi,

the library bits seem straightforward enough to go in now. Of course the 
substantive issue seems C++ front end diagnostics, post 4.7.0 material.

Sanity checked x86_64-linux.

Thanks,
Paolo.

///////////////////
2012-02-05  Jeffrey Yasskin  <jyasskin@gcc.gnu.org>
	    Paolo Carlini  <paolo.carlini@oracle.com>

	PR libstdc++/52119
	* include/std/limits (__glibcxx_min): Fix to aboid undefined behavior.

Patch

Index: include/std/limits
===================================================================
--- include/std/limits	(revision 183904)
+++ include/std/limits	(working copy)
@@ -1,7 +1,7 @@ 
 // The template and inlines for the numeric_limits classes. -*- C++ -*-
 
 // Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-// 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+// 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -129,7 +129,7 @@ 
 #define __glibcxx_signed(T)	((T)(-1) < 0)
 
 #define __glibcxx_min(T) \
-  (__glibcxx_signed (T) ? (T)1 << __glibcxx_digits (T) : (T)0)
+  (__glibcxx_signed (T) ? -__glibcxx_max (T) - 1 : (T)0)
 
 #define __glibcxx_max(T) \
   (__glibcxx_signed (T) ? \