public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/33381]  New: [4.2 regression] miscompilation casting signed long to void*
@ 2007-09-10 23:47 debian-gcc at lists dot debian dot org
  2007-09-11  3:32 ` [Bug target/33381] " mmitchel at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: debian-gcc at lists dot debian dot org @ 2007-09-10 23:47 UTC (permalink / raw)
  To: gcc-bugs

[forwarded from http://bugs.debian.org/440545]

seen with 4.2 branch 20070902, works with 4,1 branch and trunk

  Matthias

Output from attached program, if compiled with optimization level -O2:
>From 0 to 2:
 0 - In: -1, -1 (0xffffffffffffffff), Out: -1
 1 - In: 0, 0 (0xffffffffffffffff), Out: 0
 2 - In: 1, 1 (0xffffffffffffffff), Out: 1
>From 1 to 3:
 1 - In: 0, 0 ((nil)), Out: 0
 2 - In: 1, 1 (0x1), Out: 1
 3 - In: 2, 2 (0x2), Out: 2

 Should be
>From 0 to 2:
 0 - In: -1, -1 (0xffffffffffffffff), Out: -1
 1 - In: 0, 0 ((nil)), Out: 0
 2 - In: 1, 1 (0x1), Out: 1
>From 1 to 3:
 1 - In: 0, 0 ((nil)), Out: 0
 2 - In: 1, 1 (0x1), Out: 1
 3 - In: 2, 2 (0x2), Out: 2


#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int i = 0;

  printf("From 0 to 2:\n");
  for (i = 0; i < 3; i++) {
    int iin = i - 1;
    signed long lin = iin;
    void *pin = (void *) lin;
    signed long iout = (signed long) pin;

    printf(" %d - In: %d, %ld (%p), Out: %ld\n", i, iin, lin, pin, iout);
  }

  printf("From 1 to 3:\n");
  for (i = 1; i < 4; i++) {
    int iin = i - 1;
    signed long lin = iin;
    void *pin = (void *) lin;
    signed long iout = (signed long) pin;

    printf(" %d - In: %d, %ld (%p), Out: %ld\n", i, iin, lin, pin, iout);
  }

  return EXIT_SUCCESS;
}


-- 
           Summary: [4.2 regression] miscompilation casting signed long to
                    void*
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: debian-gcc at lists dot debian dot org
GCC target triplet: x64_86-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33381


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/33381] [4.2 regression] miscompilation casting signed long to void*
  2007-09-10 23:47 [Bug target/33381] New: [4.2 regression] miscompilation casting signed long to void* debian-gcc at lists dot debian dot org
@ 2007-09-11  3:32 ` mmitchel at gcc dot gnu dot org
  2007-09-11 10:21 ` pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-09-11  3:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from mmitchel at gcc dot gnu dot org  2007-09-11 03:32 -------
Ian --

Is this a VRP issue?

Thanks,

-- Mark


-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ian at airs dot com
           Priority|P3                          |P1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33381


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/33381] [4.2 regression] miscompilation casting signed long to void*
  2007-09-10 23:47 [Bug target/33381] New: [4.2 regression] miscompilation casting signed long to void* debian-gcc at lists dot debian dot org
  2007-09-11  3:32 ` [Bug target/33381] " mmitchel at gcc dot gnu dot org
@ 2007-09-11 10:21 ` pinskia at gcc dot gnu dot org
  2007-09-11 11:31 ` rguenth at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-09-11 10:21 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.2.3


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33381


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/33381] [4.2 regression] miscompilation casting signed long to void*
  2007-09-10 23:47 [Bug target/33381] New: [4.2 regression] miscompilation casting signed long to void* debian-gcc at lists dot debian dot org
  2007-09-11  3:32 ` [Bug target/33381] " mmitchel at gcc dot gnu dot org
  2007-09-11 10:21 ` pinskia at gcc dot gnu dot org
@ 2007-09-11 11:31 ` rguenth at gcc dot gnu dot org
  2007-09-11 11:34 ` rguenth at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-09-11 11:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2007-09-11 11:31 -------
A bug in VRP respective its friend SCEV.

  iin_5 = i_1 - 1;
  lin_6 = iin_5;
  pin_7 = (void *) iin_5;
  iout_8 = iin_5;
  printf (&" %d - In: %d, %ld (%p), Out: %ld\n"[0], i_1, iin_5, iin_5, pin_7,
iin_5);
  i_9 = i_1 + 1;

  (scalar = pin_7)
  (scalar_evolution = {-1B, +, 1B}_1))
)
(instantiate_parameters
  (loop_nb = 1)
  (chrec = {-1B, +, 1B}_1)
  (res = {-1B, +, 1B}_1))
Found new range for pin_7: [-1B, -1B]

Value ranges after VRP:

i_1: VARYING
i_2: ~[0, 0]  EQUIVALENCES: { } (0 elements)
iin_5: [-1, 1]  EQUIVALENCES: { } (0 elements)
lin_6: [-1, 1]  EQUIVALENCES: { iin_5 } (1 elements)
pin_7: [-1B, -1B]  EQUIVALENCES: { } (0 elements)

<L0>:;
  iin_5 = i_27 - 1;
  lin_6 = iin_5;
  pin_7 = (void *) iin_5;
  iout_8 = iin_5;
  printf (&" %d - In: %d, %ld (%p), Out: %ld\n"[0], i_27, iin_5, iin_5, -1B,
iin_5);
  i_9 = i_27 + 1;


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-09-11 11:31:46
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33381


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/33381] [4.2 regression] miscompilation casting signed long to void*
  2007-09-10 23:47 [Bug target/33381] New: [4.2 regression] miscompilation casting signed long to void* debian-gcc at lists dot debian dot org
                   ` (2 preceding siblings ...)
  2007-09-11 11:31 ` rguenth at gcc dot gnu dot org
@ 2007-09-11 11:34 ` rguenth at gcc dot gnu dot org
  2007-09-21 13:04 ` rguenth at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-09-11 11:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2007-09-11 11:33 -------
I think this is related (but not exactly dup) of PR33099.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |33099


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33381


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/33381] [4.2 regression] miscompilation casting signed long to void*
  2007-09-10 23:47 [Bug target/33381] New: [4.2 regression] miscompilation casting signed long to void* debian-gcc at lists dot debian dot org
                   ` (3 preceding siblings ...)
  2007-09-11 11:34 ` rguenth at gcc dot gnu dot org
@ 2007-09-21 13:04 ` rguenth at gcc dot gnu dot org
  2007-09-21 13:37 ` rguenth at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-09-21 13:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2007-09-21 13:04 -------
Shorter testcase:

void x(void *data);
void test()
{
  long i;
  for (i = 0; i < 5; i++) 
    if (i > 0)
      x((void *)(i - 1));
}


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33381


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/33381] [4.2 regression] miscompilation casting signed long to void*
  2007-09-10 23:47 [Bug target/33381] New: [4.2 regression] miscompilation casting signed long to void* debian-gcc at lists dot debian dot org
                   ` (4 preceding siblings ...)
  2007-09-21 13:04 ` rguenth at gcc dot gnu dot org
@ 2007-09-21 13:37 ` rguenth at gcc dot gnu dot org
  2007-09-25  7:16 ` debian-gcc at lists dot debian dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-09-21 13:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2007-09-21 13:36 -------
This was fixed by the introduction of pointer-plus, which removed all traces
of fold_used_pointer* in tree-scalar-evolution.c.

A safe patch would go along the following:

Index: tree-vrp.c
===================================================================
--- tree-vrp.c  (revision 128649)
+++ tree-vrp.c  (working copy)
@@ -2482,6 +2482,13 @@ adjust_range_with_scev (value_range_t *v
   if (vr->type == VR_ANTI_RANGE)
     return;

+  /* Don't try to feed SCEV with casts to pointer type.  */
+  if (TREE_CODE (stmt) == MODIFY_EXPR
+      && (TREE_CODE (TREE_OPERAND (stmt, 1)) == NOP_EXPR
+         || TREE_CODE (TREE_OPERAND (stmt, 1)) == CONVERT_EXPR)
+      && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (stmt, 1))))
+    return;
+
   chrec = instantiate_parameters (loop, analyze_scalar_evolution (loop, var));
   if (TREE_CODE (chrec) != POLYNOMIAL_CHREC)
     return;


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rguenth at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2007-09-11 11:31:46         |2007-09-21 13:36:53
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33381


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/33381] [4.2 regression] miscompilation casting signed long to void*
  2007-09-10 23:47 [Bug target/33381] New: [4.2 regression] miscompilation casting signed long to void* debian-gcc at lists dot debian dot org
                   ` (5 preceding siblings ...)
  2007-09-21 13:37 ` rguenth at gcc dot gnu dot org
@ 2007-09-25  7:16 ` debian-gcc at lists dot debian dot org
  2007-09-25  8:25 ` rguenther at suse dot de
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: debian-gcc at lists dot debian dot org @ 2007-09-25  7:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from debian-gcc at lists dot debian dot org  2007-09-25 07:15 -------
comparing 4.2 20070902 with 4.2 20070925 + plus the proposed patch, I see two
regressions:

FAIL: g++.dg/ext/vla4.C  (test for errors, line 10)
FAIL: g++.dg/other/unused1.C scan-assembler
(string|ascii?)z?\\t"class2("|\\\\\\\\000)

Currently checking 20070925 without the proposed patch.

  Matthias


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33381


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/33381] [4.2 regression] miscompilation casting signed long to void*
  2007-09-10 23:47 [Bug target/33381] New: [4.2 regression] miscompilation casting signed long to void* debian-gcc at lists dot debian dot org
                   ` (6 preceding siblings ...)
  2007-09-25  7:16 ` debian-gcc at lists dot debian dot org
@ 2007-09-25  8:25 ` rguenther at suse dot de
  2007-09-25 13:37 ` debian-gcc at lists dot debian dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenther at suse dot de @ 2007-09-25  8:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from rguenther at suse dot de  2007-09-25 08:25 -------
Subject: Re:  [4.2 regression] miscompilation casting signed
 long to void*

On Tue, 25 Sep 2007, debian-gcc at lists dot debian dot org wrote:

> ------- Comment #6 from debian-gcc at lists dot debian dot org  2007-09-25 07:15 -------
> comparing 4.2 20070902 with 4.2 20070925 + plus the proposed patch, I see two
> regressions:
> 
> FAIL: g++.dg/ext/vla4.C  (test for errors, line 10)
> FAIL: g++.dg/other/unused1.C scan-assembler
> (string|ascii?)z?\\t"class2("|\\\\\\\\000)
> 
> Currently checking 20070925 without the proposed patch.

They also happened w/o the patch for me.

Richard.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33381


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/33381] [4.2 regression] miscompilation casting signed long to void*
  2007-09-10 23:47 [Bug target/33381] New: [4.2 regression] miscompilation casting signed long to void* debian-gcc at lists dot debian dot org
                   ` (7 preceding siblings ...)
  2007-09-25  8:25 ` rguenther at suse dot de
@ 2007-09-25 13:37 ` debian-gcc at lists dot debian dot org
  2007-10-10  9:25 ` rguenth at gcc dot gnu dot org
  2007-10-10  9:25 ` rguenth at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: debian-gcc at lists dot debian dot org @ 2007-09-25 13:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from debian-gcc at lists dot debian dot org  2007-09-25 13:36 -------
> > Currently checking 20070925 without the proposed patch.
> 
> They also happened w/o the patch for me.

same here, Matthias


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33381


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/33381] [4.2 regression] miscompilation casting signed long to void*
  2007-09-10 23:47 [Bug target/33381] New: [4.2 regression] miscompilation casting signed long to void* debian-gcc at lists dot debian dot org
                   ` (9 preceding siblings ...)
  2007-10-10  9:25 ` rguenth at gcc dot gnu dot org
@ 2007-10-10  9:25 ` rguenth at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-10-10  9:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from rguenth at gcc dot gnu dot org  2007-10-10 09:24 -------
Fixed.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33381


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/33381] [4.2 regression] miscompilation casting signed long to void*
  2007-09-10 23:47 [Bug target/33381] New: [4.2 regression] miscompilation casting signed long to void* debian-gcc at lists dot debian dot org
                   ` (8 preceding siblings ...)
  2007-09-25 13:37 ` debian-gcc at lists dot debian dot org
@ 2007-10-10  9:25 ` rguenth at gcc dot gnu dot org
  2007-10-10  9:25 ` rguenth at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-10-10  9:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from rguenth at gcc dot gnu dot org  2007-10-10 09:24 -------
Subject: Bug 33381

Author: rguenth
Date: Wed Oct 10 09:24:43 2007
New Revision: 129197

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129197
Log:
2007-10-10  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/33099
        PR tree-optimization/33381
        * tree-vrp.c (adjust_range_with_scev): Do not adjust ranges
        from pointer typed chrecs.

        * gcc.c-torture/execute/pr33099.c: New testcase.
        * gcc.c-torture/execute/pr33381.c: Likewise.

Added:
    branches/gcc-4_2-branch/gcc/testsuite/gcc.c-torture/execute/pr33099.c
    branches/gcc-4_2-branch/gcc/testsuite/gcc.c-torture/execute/pr33381.c
Modified:
    branches/gcc-4_2-branch/gcc/ChangeLog
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_2-branch/gcc/tree-vrp.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33381


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2007-10-10  9:25 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-10 23:47 [Bug target/33381] New: [4.2 regression] miscompilation casting signed long to void* debian-gcc at lists dot debian dot org
2007-09-11  3:32 ` [Bug target/33381] " mmitchel at gcc dot gnu dot org
2007-09-11 10:21 ` pinskia at gcc dot gnu dot org
2007-09-11 11:31 ` rguenth at gcc dot gnu dot org
2007-09-11 11:34 ` rguenth at gcc dot gnu dot org
2007-09-21 13:04 ` rguenth at gcc dot gnu dot org
2007-09-21 13:37 ` rguenth at gcc dot gnu dot org
2007-09-25  7:16 ` debian-gcc at lists dot debian dot org
2007-09-25  8:25 ` rguenther at suse dot de
2007-09-25 13:37 ` debian-gcc at lists dot debian dot org
2007-10-10  9:25 ` rguenth at gcc dot gnu dot org
2007-10-10  9:25 ` rguenth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).