public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/24635] New: Wrong statement reordering
@ 2005-11-02 13:44 worm at arrakis dot es
2005-11-02 14:51 ` [Bug c/24635] " rguenth at gcc dot gnu dot org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: worm at arrakis dot es @ 2005-11-02 13:44 UTC (permalink / raw)
To: gcc-bugs
/*
* Summary:
* Wrong statement reordering
* Description:
* If you run this program, it will produce an output of 1.
* The reason is that the assignment V1=0 which should be
* executed before the call to cl_throw() is moved after
* this call, and hence when cl_throw() invokes longjmp()
* the variable is not assigned a value.
* Operating system:
* Ubuntu 5.10
* Machine:
* Pentium 4
* Compiler: (gcc -v)
* Using built-in specs.
* Target: i486-linux-gnu
* Configured with: ../src/configure -v
--enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr
--with-gxx-include-dir=/usr/include/c++/4.0.2 --enable-shared
--with-system-zlib --libexecdir=/usr/lib --enable-nls
--without-included-gettext --enable-threads=posix --program-suffix=-4.0
--enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu
--enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk
--enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre
--enable-mpfr --disable-werror --enable-checking=release i486-linux-gnu
* Thread model: posix
* gcc version 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9)
*/
typedef int __jmp_buf[6];
typedef struct
{
unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))];
} __sigset_t;
typedef struct __jmp_buf_tag
{
__jmp_buf __jmpbuf;
int __mask_was_saved;
__sigset_t __saved_mask;
} jmp_buf[1];
extern int setjmp (jmp_buf __env) __attribute__ ((__nothrow__));
extern void longjmp (struct __jmp_buf_tag __env[1], int __val)
__attribute__ ((__nothrow__)) __attribute__ ((__noreturn__));
extern int printf (__const char *__restrict __format, ...);
static jmp_buf foo;
extern void cl_throw();
void cl_throw()
{
longjmp(foo, 1);
}
int L1foo(int V0)
{
volatile int V1 = V0;
if (setjmp (foo)) {
goto L9;
}
V1= 0;
cl_throw();
L9:;
return V1;
}
int main ()
{
printf("%d\n", L1foo(1));
return 0;
}
--
Summary: Wrong statement reordering
Product: gcc
Version: 4.0.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: worm at arrakis dot es
GCC host triplet: i486-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24635
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/24635] Wrong statement reordering
2005-11-02 13:44 [Bug c/24635] New: Wrong statement reordering worm at arrakis dot es
@ 2005-11-02 14:51 ` rguenth at gcc dot gnu dot org
2005-11-02 14:55 ` pinskia at gcc dot gnu dot org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-11-02 14:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rguenth at gcc dot gnu dot org 2005-11-02 14:51 -------
I cannot reproduce this on 4.0.1 or CVS HEAD of 4.0 (20050919), nor on 4.1.0.
What optimization options did you use?
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Known to work| |4.1.0 4.0.1
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24635
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/24635] Wrong statement reordering
2005-11-02 13:44 [Bug c/24635] New: Wrong statement reordering worm at arrakis dot es
2005-11-02 14:51 ` [Bug c/24635] " rguenth at gcc dot gnu dot org
@ 2005-11-02 14:55 ` pinskia at gcc dot gnu dot org
2005-11-02 14:56 ` [Bug middle-end/24635] " pinskia at gcc dot gnu dot org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-02 14:55 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2005-11-02 14:55 -------
I cannot reproduce this with the compiler version you have.
GNU C version 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9)
(x86_64-linux-gnu)
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work|4.1.0 4.0.1 |4.1.0 4.0.1 4.0.2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24635
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/24635] Wrong statement reordering
2005-11-02 13:44 [Bug c/24635] New: Wrong statement reordering worm at arrakis dot es
2005-11-02 14:51 ` [Bug c/24635] " rguenth at gcc dot gnu dot org
2005-11-02 14:55 ` pinskia at gcc dot gnu dot org
@ 2005-11-02 14:56 ` pinskia at gcc dot gnu dot org
2005-11-04 12:13 ` worm at arrakis dot es
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-02 14:56 UTC (permalink / raw)
To: gcc-bugs
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu dot
| |org
Status|UNCONFIRMED |WAITING
Component|c |middle-end
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24635
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/24635] Wrong statement reordering
2005-11-02 13:44 [Bug c/24635] New: Wrong statement reordering worm at arrakis dot es
` (2 preceding siblings ...)
2005-11-02 14:56 ` [Bug middle-end/24635] " pinskia at gcc dot gnu dot org
@ 2005-11-04 12:13 ` worm at arrakis dot es
2005-11-04 13:25 ` pinskia at gcc dot gnu dot org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: worm at arrakis dot es @ 2005-11-04 12:13 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from worm at arrakis dot es 2005-11-04 12:13 -------
Created an attachment (id=10143)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10143&action=view)
This one triggers the bug
The new file definitely triggers the problem with statement reordering if
compiled with (-O2), but after a second read of the standard, I am not sure
whether arguments of a function are implicitely declared volatile or not.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24635
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/24635] Wrong statement reordering
2005-11-02 13:44 [Bug c/24635] New: Wrong statement reordering worm at arrakis dot es
` (3 preceding siblings ...)
2005-11-04 12:13 ` worm at arrakis dot es
@ 2005-11-04 13:25 ` pinskia at gcc dot gnu dot org
2005-11-04 13:35 ` worm at arrakis dot es
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-04 13:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pinskia at gcc dot gnu dot org 2005-11-04 13:25 -------
I still cannot reproduce it.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24635
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/24635] Wrong statement reordering
2005-11-02 13:44 [Bug c/24635] New: Wrong statement reordering worm at arrakis dot es
` (4 preceding siblings ...)
2005-11-04 13:25 ` pinskia at gcc dot gnu dot org
@ 2005-11-04 13:35 ` worm at arrakis dot es
2005-11-04 14:05 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: worm at arrakis dot es @ 2005-11-04 13:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from worm at arrakis dot es 2005-11-04 13:35 -------
Sorry for my stupidity -- the jet-lag after a long trip
seems to affect me --.
Remove the "volatile" statement from the arguments list
of L1foo.
Then the assignments to the variable V1 are moved after
the call to cl_throw() and are never executed. I am not
sure whether this conforms to the standard or not.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24635
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/24635] Wrong statement reordering
2005-11-02 13:44 [Bug c/24635] New: Wrong statement reordering worm at arrakis dot es
` (5 preceding siblings ...)
2005-11-04 13:35 ` worm at arrakis dot es
@ 2005-11-04 14:05 ` pinskia at gcc dot gnu dot org
2005-11-04 15:24 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-04 14:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pinskia at gcc dot gnu dot org 2005-11-04 14:05 -------
Removing volatile will change the semantics of the program and therefor not a
bug. GCC docs mention with (I cannot find right now as I am at a Kiosk and it
is hard to find anything) longjmp, volatile is required.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24635
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/24635] Wrong statement reordering
2005-11-02 13:44 [Bug c/24635] New: Wrong statement reordering worm at arrakis dot es
` (6 preceding siblings ...)
2005-11-04 14:05 ` pinskia at gcc dot gnu dot org
@ 2005-11-04 15:24 ` pinskia at gcc dot gnu dot org
2005-11-04 15:25 ` pinskia at gcc dot gnu dot org
2005-11-04 15:25 ` pinskia at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-04 15:24 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from pinskia at gcc dot gnu dot org 2005-11-04 15:24 -------
Woops, that should have been ...
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|0000-00-00 00:00:00 |2005-11-04 15:24:49
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24635
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/24635] Wrong statement reordering
2005-11-02 13:44 [Bug c/24635] New: Wrong statement reordering worm at arrakis dot es
` (8 preceding siblings ...)
2005-11-04 15:25 ` pinskia at gcc dot gnu dot org
@ 2005-11-04 15:25 ` pinskia at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-04 15:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from pinskia at gcc dot gnu dot org 2005-11-04 15:24 -------
Woops, that should have been ...
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|FIXED |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24635
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/24635] Wrong statement reordering
2005-11-02 13:44 [Bug c/24635] New: Wrong statement reordering worm at arrakis dot es
` (7 preceding siblings ...)
2005-11-04 15:24 ` pinskia at gcc dot gnu dot org
@ 2005-11-04 15:25 ` pinskia at gcc dot gnu dot org
2005-11-04 15:25 ` pinskia at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-04 15:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from pinskia at gcc dot gnu dot org 2005-11-04 15:25 -------
Closed as invalid.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24635
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2005-11-04 15:25 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-02 13:44 [Bug c/24635] New: Wrong statement reordering worm at arrakis dot es
2005-11-02 14:51 ` [Bug c/24635] " rguenth at gcc dot gnu dot org
2005-11-02 14:55 ` pinskia at gcc dot gnu dot org
2005-11-02 14:56 ` [Bug middle-end/24635] " pinskia at gcc dot gnu dot org
2005-11-04 12:13 ` worm at arrakis dot es
2005-11-04 13:25 ` pinskia at gcc dot gnu dot org
2005-11-04 13:35 ` worm at arrakis dot es
2005-11-04 14:05 ` pinskia at gcc dot gnu dot org
2005-11-04 15:24 ` pinskia at gcc dot gnu dot org
2005-11-04 15:25 ` pinskia at gcc dot gnu dot org
2005-11-04 15:25 ` pinskia 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).