This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR52862


This removes the special casing of zero from convert_to_pointer
(why would only that need overflow flag handling?  and why would
the generic code below not properly handle it ...)

That sounds better than papering over the issue with noting
that integer_zerop can return true for non-INTEGER_CSTs and
checking for that before querying TREE_OVERFLOW.

Bootstrap and regtest pending on x86_64-unknown-linux-gnu.

Richard.

2012-04-12  Richard Guenther  <rguenther@suse.de>

	PR c/52862
	* convert.c (convert_to_pointer): Remove special-casing of
	zero.

	* gcc.dg/pr52862.c: New testcase.

Index: gcc/convert.c
===================================================================
*** gcc/convert.c	(revision 186373)
--- gcc/convert.c	(working copy)
*************** convert_to_pointer (tree type, tree expr
*** 44,54 ****
    if (TREE_TYPE (expr) == type)
      return expr;
  
-   /* Propagate overflow to the NULL pointer.  */
-   if (integer_zerop (expr))
-     return force_fit_type_double (type, double_int_zero, 0,
- 				  TREE_OVERFLOW (expr));
- 
    switch (TREE_CODE (TREE_TYPE (expr)))
      {
      case POINTER_TYPE:
--- 44,49 ----
Index: gcc/testsuite/gcc.dg/pr52862.c
===================================================================
*** gcc/testsuite/gcc.dg/pr52862.c	(revision 0)
--- gcc/testsuite/gcc.dg/pr52862.c	(revision 0)
***************
*** 0 ****
--- 1,9 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O" } */
+ 
+ void ASMAtomicWritePtrVoid(const void *pv);
+ void rtThreadDestroy(void)
+ {
+   void * const pvTypeChecked = ((void *)0);
+   ASMAtomicWritePtrVoid((void *)(pvTypeChecked));
+ }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]