public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/17078] New: Jump into if(0)-substatement fails
@ 2004-08-18 11:05 paul dot woegerer at nsc dot com
  2004-08-18 12:00 ` [Bug rtl-optimization/17078] " reichelt at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: paul dot woegerer at nsc dot com @ 2004-08-18 11:05 UTC (permalink / raw)
  To: gcc-bugs

On GCC 3.4.1 the following goto example generates wrong code.

On GCC 3.3.3 the return vale of this example is 1 as it should
be according to ANSI C "... If the first substatement is reached
via a label, the second substatment is not executed ..."
(see 6.6.4.1).

It looks to me that cfg_cleanup or some reachability test is not
taking into account that the if(0)-basic-block is entered via the
label and behaves too optimistic in elimiating it.

int main(int argc, char **argv)
{
  int i = 0;
  goto useless;
  if(0)
    {
      useless:
      i = 1;
    }
  else
    {
      i = 2;
    }
  return i;
}

-- 
           Summary: Jump into if(0)-substatement fails
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: paul dot woegerer at nsc dot com
                CC: gcc-bugs at gcc dot gnu dot org,tal dot agmon at nsc dot
                    com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug rtl-optimization/17078] Jump into if(0)-substatement fails
  2004-08-18 11:05 [Bug rtl-optimization/17078] New: Jump into if(0)-substatement fails paul dot woegerer at nsc dot com
@ 2004-08-18 12:00 ` reichelt at gcc dot gnu dot org
  2004-08-19  7:27 ` [Bug rtl-optimization/17078] [3.4 regression] " paul dot woegerer at nsc dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2004-08-18 12:00 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From reichelt at gcc dot gnu dot org  2004-08-18 12:00 -------
Confirmed.

Remarks:
* This only happens with -O0.
* The return value is not even 0 or 2, but 16.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |reichelt at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |monitored, wrong-code
      Known to fail|                            |3.4.0 3.4.1
      Known to work|                            |3.3.4 3.5.0
   Last reconfirmed|0000-00-00 00:00:00         |2004-08-18 12:00:29
               date|                            |
   Target Milestone|---                         |3.4.2


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


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

* [Bug rtl-optimization/17078] [3.4 regression] Jump into if(0)-substatement fails
  2004-08-18 11:05 [Bug rtl-optimization/17078] New: Jump into if(0)-substatement fails paul dot woegerer at nsc dot com
  2004-08-18 12:00 ` [Bug rtl-optimization/17078] " reichelt at gcc dot gnu dot org
@ 2004-08-19  7:27 ` paul dot woegerer at nsc dot com
  2004-08-19  7:54 ` paul dot woegerer at nsc dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: paul dot woegerer at nsc dot com @ 2004-08-19  7:27 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From paul dot woegerer at nsc dot com  2004-08-19 07:26 -------
(In reply to comment #1)
> Confirmed.
> 
> Remarks:
> * This only happens with -O0.
> * The return value is not even 0 or 2, but 16.
> 

With -O0 i also get return value 16. But with
-O2, -O3 and -Os i get 164 as return value.

I used GCC 3.4.1 in the following configuration:
Reading specs from /usr/local/gcc-3.4.1-native/lib/gcc/i686-pc-linux-gnu/3.4.1/specs
Configured with: ../gcc-3.4.1/configure --enable-languages=c,c++
--prefix=/usr/local/gcc-3.4.1-native
Thread model: posix
gcc version 3.4.1


-- 


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


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

* [Bug rtl-optimization/17078] [3.4 regression] Jump into if(0)-substatement fails
  2004-08-18 11:05 [Bug rtl-optimization/17078] New: Jump into if(0)-substatement fails paul dot woegerer at nsc dot com
  2004-08-18 12:00 ` [Bug rtl-optimization/17078] " reichelt at gcc dot gnu dot org
  2004-08-19  7:27 ` [Bug rtl-optimization/17078] [3.4 regression] " paul dot woegerer at nsc dot com
@ 2004-08-19  7:54 ` paul dot woegerer at nsc dot com
  2004-08-19 10:21 ` reichelt at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: paul dot woegerer at nsc dot com @ 2004-08-19  7:54 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From paul dot woegerer at nsc dot com  2004-08-19 07:54 -------
Subject: Re:  [3.4 regression] Jump into if(
 0) -substatement fails

Morning Tal,

So i was wrong yesterday when i said something is wrong with the header 
files.
Something is wrong with the compiler. Is this bug already reported to GNUs
bugzilla?

Paul

 




"paul dot woegerer at nsc dot com" <gcc-bugzilla@gcc.gnu.org>
08/19/2004 09:26 AM
Please respond to gcc-bugzilla
 
        To:     Paul.Woegerer@nsc.com
        cc: 
        Subject:        [Bug rtl-optimization/17078] [3.4 regression] Jump 
into if(0) -substatement fails



------- Additional Comments From paul dot woegerer at nsc dot com 
2004-08-19 07:26 -------
(In reply to comment #1)
> Confirmed.
> 
> Remarks:
> * This only happens with -O0.
> * The return value is not even 0 or 2, but 16.
> 

With -O0 i also get return value 16. But with
-O2, -O3 and -Os i get 164 as return value.

I used GCC 3.4.1 in the following configuration:
Reading specs from 
/usr/local/gcc-3.4.1-native/lib/gcc/i686-pc-linux-gnu/3.4.1/specs
Configured with: ../gcc-3.4.1/configure --enable-languages=c,c++
--prefix=/usr/local/gcc-3.4.1-native
Thread model: posix
gcc version 3.4.1


-- 


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

------- You are receiving this mail because: -------
You reported the bug, or are watching the reporter.






-- 


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


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

* [Bug rtl-optimization/17078] [3.4 regression] Jump into if(0)-substatement fails
  2004-08-18 11:05 [Bug rtl-optimization/17078] New: Jump into if(0)-substatement fails paul dot woegerer at nsc dot com
                   ` (2 preceding siblings ...)
  2004-08-19  7:54 ` paul dot woegerer at nsc dot com
@ 2004-08-19 10:21 ` reichelt at gcc dot gnu dot org
  2004-08-22 23:50 ` mmitchel at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2004-08-19 10:21 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From reichelt at gcc dot gnu dot org  2004-08-19 10:21 -------
> With -O0 i also get return value 16. But with
> -O2, -O3 and -Os i get 164 as return value.

Hmm. With the C frontend I only get wrong numbers with -O0.
With the C++ frontend I get wrong numbers for all optimizations:
-O0 -O1 -O2 -O3 -Os. (I mostly get zeros, but that's not a
contradiction to the 164 mentioned above, since there's probably
some uninitialized memory involved).

Anyway, GCC is at fault here.


-- 


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


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

* [Bug rtl-optimization/17078] [3.4 regression] Jump into if(0)-substatement fails
  2004-08-18 11:05 [Bug rtl-optimization/17078] New: Jump into if(0)-substatement fails paul dot woegerer at nsc dot com
                   ` (3 preceding siblings ...)
  2004-08-19 10:21 ` reichelt at gcc dot gnu dot org
@ 2004-08-22 23:50 ` mmitchel at gcc dot gnu dot org
  2004-08-24  4:03 ` cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-08-22 23:50 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-08-22 23:50 -------
Roger, this looks to be a bug in expand_unreachable_stmt.

In particular, it looks like the return statement is never expanded because it
is considered unreachable due to the earlier goto.  However, since the
then-clause of the if-statment falls off the bottom, the return-statement
becomes reachable again.  Here, expand_unreachable_if_stmt should be returning
true, but instead returns false.

I've assigned this bug to you.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |roger at eyesopen dot com
         AssignedTo|unassigned at gcc dot gnu   |roger at eyesopen dot com
                   |dot org                     |
             Status|NEW                         |ASSIGNED


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


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

* [Bug rtl-optimization/17078] [3.4 regression] Jump into if(0)-substatement fails
  2004-08-18 11:05 [Bug rtl-optimization/17078] New: Jump into if(0)-substatement fails paul dot woegerer at nsc dot com
                   ` (4 preceding siblings ...)
  2004-08-22 23:50 ` mmitchel at gcc dot gnu dot org
@ 2004-08-24  4:03 ` cvs-commit at gcc dot gnu dot org
  2004-08-24  4:09 ` pinskia at gcc dot gnu dot org
  2004-08-24  4:23 ` cvs-commit at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-08-24  4:03 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-08-24 04:02 -------
Subject: Bug 17078

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	sayle@gcc.gnu.org	2004-08-24 04:02:46

Modified files:
	gcc            : ChangeLog c-semantics.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.c-torture/execute: pr17078-1.c 

Log message:
	PR rtl-optimization/17078
	* c-semantics.c (expand_unreachable_if_stmt): If the end of the
	specified statement list is reachable, always return a non-NULL
	pointer.  If necessary, return error_mark_node.
	
	* gcc.c-torture/execute/pr17078-1.c: New test case.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.589&r2=2.2326.2.590
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-semantics.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.74.4.2&r2=1.74.4.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.256&r2=1.3389.2.257
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/pr17078-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1



-- 


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


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

* [Bug rtl-optimization/17078] [3.4 regression] Jump into if(0)-substatement fails
  2004-08-18 11:05 [Bug rtl-optimization/17078] New: Jump into if(0)-substatement fails paul dot woegerer at nsc dot com
                   ` (5 preceding siblings ...)
  2004-08-24  4:03 ` cvs-commit at gcc dot gnu dot org
@ 2004-08-24  4:09 ` pinskia at gcc dot gnu dot org
  2004-08-24  4:23 ` cvs-commit at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-24  4:09 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-24 04:09 -------
Fixed.

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


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


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

* [Bug rtl-optimization/17078] [3.4 regression] Jump into if(0)-substatement fails
  2004-08-18 11:05 [Bug rtl-optimization/17078] New: Jump into if(0)-substatement fails paul dot woegerer at nsc dot com
                   ` (6 preceding siblings ...)
  2004-08-24  4:09 ` pinskia at gcc dot gnu dot org
@ 2004-08-24  4:23 ` cvs-commit at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-08-24  4:23 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-08-24 04:23 -------
Subject: Bug 17078

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	sayle@gcc.gnu.org	2004-08-24 04:23:31

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.c-torture/execute: pr17078-1.c 

Log message:
	PR rtl-optimization/17078
	* gcc.c-torture/execute/pr17078-1.c: New test case.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4177&r2=1.4178
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/pr17078-1.c.diff?cvsroot=gcc&r1=1.1&r2=1.2



-- 


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


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

end of thread, other threads:[~2004-08-24  4:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-18 11:05 [Bug rtl-optimization/17078] New: Jump into if(0)-substatement fails paul dot woegerer at nsc dot com
2004-08-18 12:00 ` [Bug rtl-optimization/17078] " reichelt at gcc dot gnu dot org
2004-08-19  7:27 ` [Bug rtl-optimization/17078] [3.4 regression] " paul dot woegerer at nsc dot com
2004-08-19  7:54 ` paul dot woegerer at nsc dot com
2004-08-19 10:21 ` reichelt at gcc dot gnu dot org
2004-08-22 23:50 ` mmitchel at gcc dot gnu dot org
2004-08-24  4:03 ` cvs-commit at gcc dot gnu dot org
2004-08-24  4:09 ` pinskia at gcc dot gnu dot org
2004-08-24  4:23 ` cvs-commit 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).