* [Bug middle-end/36124] conditional loop becomes infinite loop in -O2 (gcc 4.2 -> 4.3 regression)
2008-05-04 16:26 [Bug c/36124] New: conditional loop becomes infinite loop in -O2 (gcc 4.2 -> 4.3 regression) cyprien+gccbug at cypou dot net
@ 2008-05-04 16:35 ` pinskia at gcc dot gnu dot org
2008-05-04 16:42 ` cyprien+gccbug at cypou dot net
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-05-04 16:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2008-05-04 16:34 -------
Pointers types overflow is undefined which is what you are seeing.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|c |middle-end
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36124
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/36124] conditional loop becomes infinite loop in -O2 (gcc 4.2 -> 4.3 regression)
2008-05-04 16:26 [Bug c/36124] New: conditional loop becomes infinite loop in -O2 (gcc 4.2 -> 4.3 regression) cyprien+gccbug at cypou dot net
2008-05-04 16:35 ` [Bug middle-end/36124] " pinskia at gcc dot gnu dot org
@ 2008-05-04 16:42 ` cyprien+gccbug at cypou dot net
2008-05-04 16:45 ` pinskia at gcc dot gnu dot org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: cyprien+gccbug at cypou dot net @ 2008-05-04 16:42 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from cyprien+gccbug at cypou dot net 2008-05-04 16:41 -------
shouldn't gcc report a warning in this case ?
because silently entering an infinite loop is not very kind...
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36124
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/36124] conditional loop becomes infinite loop in -O2 (gcc 4.2 -> 4.3 regression)
2008-05-04 16:26 [Bug c/36124] New: conditional loop becomes infinite loop in -O2 (gcc 4.2 -> 4.3 regression) cyprien+gccbug at cypou dot net
2008-05-04 16:35 ` [Bug middle-end/36124] " pinskia at gcc dot gnu dot org
2008-05-04 16:42 ` cyprien+gccbug at cypou dot net
@ 2008-05-04 16:45 ` pinskia at gcc dot gnu dot org
2008-05-04 17:02 ` kargl at gcc dot gnu dot org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-05-04 16:45 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pinskia at gcc dot gnu dot org 2008-05-04 16:45 -------
(In reply to comment #2)
> shouldn't gcc report a warning in this case ?
Maybe, but really depending on undefined behavior is bad too.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36124
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/36124] conditional loop becomes infinite loop in -O2 (gcc 4.2 -> 4.3 regression)
2008-05-04 16:26 [Bug c/36124] New: conditional loop becomes infinite loop in -O2 (gcc 4.2 -> 4.3 regression) cyprien+gccbug at cypou dot net
` (2 preceding siblings ...)
2008-05-04 16:45 ` pinskia at gcc dot gnu dot org
@ 2008-05-04 17:02 ` kargl at gcc dot gnu dot org
2008-05-04 17:04 ` cyprien+gccbug at cypou dot net
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: kargl at gcc dot gnu dot org @ 2008-05-04 17:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from kargl at gcc dot gnu dot org 2008-05-04 17:01 -------
(In reply to comment #2)
> shouldn't gcc report a warning in this case ?
>
> because silently entering an infinite loop is not very kind...
>
If your code invokes undefined behavior, how is gcc going
to read your mind? Maybe the programmer meant to enter
an infinite, so a warning isn't correct.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36124
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/36124] conditional loop becomes infinite loop in -O2 (gcc 4.2 -> 4.3 regression)
2008-05-04 16:26 [Bug c/36124] New: conditional loop becomes infinite loop in -O2 (gcc 4.2 -> 4.3 regression) cyprien+gccbug at cypou dot net
` (3 preceding siblings ...)
2008-05-04 17:02 ` kargl at gcc dot gnu dot org
@ 2008-05-04 17:04 ` cyprien+gccbug at cypou dot net
2008-05-04 17:10 ` pinskia at gcc dot gnu dot org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: cyprien+gccbug at cypou dot net @ 2008-05-04 17:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from cyprien+gccbug at cypou dot net 2008-05-04 17:03 -------
Now, this code should not rely on undefined behaviour:
extern void func(int,void*);
void test()
{
register long *foo = (long*) (4*sizeof(*foo)) - 1;
register int index;
for(index=0;index<4;index++)
func(index,foo--);
}
it still make an infinite loop, while last func call is done with foo parameter
(nil).
Do you mean I explicitely ask gcc to use foo as end-of-loop condition ??
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36124
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/36124] conditional loop becomes infinite loop in -O2 (gcc 4.2 -> 4.3 regression)
2008-05-04 16:26 [Bug c/36124] New: conditional loop becomes infinite loop in -O2 (gcc 4.2 -> 4.3 regression) cyprien+gccbug at cypou dot net
` (4 preceding siblings ...)
2008-05-04 17:04 ` cyprien+gccbug at cypou dot net
@ 2008-05-04 17:10 ` pinskia at gcc dot gnu dot org
2008-05-04 17:31 ` cyprien+gccbug at cypou dot net
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-05-04 17:10 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pinskia at gcc dot gnu dot org 2008-05-04 17:09 -------
>Now, this code should not rely on undefined behaviour:
It does because incrementing or decrementing to a NULL Pointer is undefined.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36124
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/36124] conditional loop becomes infinite loop in -O2 (gcc 4.2 -> 4.3 regression)
2008-05-04 16:26 [Bug c/36124] New: conditional loop becomes infinite loop in -O2 (gcc 4.2 -> 4.3 regression) cyprien+gccbug at cypou dot net
` (5 preceding siblings ...)
2008-05-04 17:10 ` pinskia at gcc dot gnu dot org
@ 2008-05-04 17:31 ` cyprien+gccbug at cypou dot net
2008-05-04 20:13 ` cyprien+gccbug at cypou dot net
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: cyprien+gccbug at cypou dot net @ 2008-05-04 17:31 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from cyprien+gccbug at cypou dot net 2008-05-04 17:31 -------
it's right, using --foo unstead of foo-- gives a better result.
But it does not make me happy (about the possibility of a bug)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36124
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/36124] conditional loop becomes infinite loop in -O2 (gcc 4.2 -> 4.3 regression)
2008-05-04 16:26 [Bug c/36124] New: conditional loop becomes infinite loop in -O2 (gcc 4.2 -> 4.3 regression) cyprien+gccbug at cypou dot net
` (6 preceding siblings ...)
2008-05-04 17:31 ` cyprien+gccbug at cypou dot net
@ 2008-05-04 20:13 ` cyprien+gccbug at cypou dot net
2008-05-07 19:43 ` rguenth at gcc dot gnu dot org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: cyprien+gccbug at cypou dot net @ 2008-05-04 20:13 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from cyprien+gccbug at cypou dot net 2008-05-04 20:13 -------
On some embedded machines, the SDRAM lays on 0x00000000 address. So it is not
so meaningless to increment or decrement from/to NULL pointer.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36124
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/36124] conditional loop becomes infinite loop in -O2 (gcc 4.2 -> 4.3 regression)
2008-05-04 16:26 [Bug c/36124] New: conditional loop becomes infinite loop in -O2 (gcc 4.2 -> 4.3 regression) cyprien+gccbug at cypou dot net
` (7 preceding siblings ...)
2008-05-04 20:13 ` cyprien+gccbug at cypou dot net
@ 2008-05-07 19:43 ` rguenth at gcc dot gnu dot org
2008-05-13 20:02 ` pinskia at gcc dot gnu dot org
2008-05-13 21:14 ` scottwood at freescale dot com
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-05-07 19:43 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from rguenth at gcc dot gnu dot org 2008-05-07 19:42 -------
decrementing a NULL pointer invokes undefined behavior, incrementing not.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36124
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/36124] conditional loop becomes infinite loop in -O2 (gcc 4.2 -> 4.3 regression)
2008-05-04 16:26 [Bug c/36124] New: conditional loop becomes infinite loop in -O2 (gcc 4.2 -> 4.3 regression) cyprien+gccbug at cypou dot net
` (8 preceding siblings ...)
2008-05-07 19:43 ` rguenth at gcc dot gnu dot org
@ 2008-05-13 20:02 ` pinskia at gcc dot gnu dot org
2008-05-13 21:14 ` scottwood at freescale dot com
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-05-13 20:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from pinskia at gcc dot gnu dot org 2008-05-13 20:02 -------
*** Bug 36232 has been marked as a duplicate of this bug. ***
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |nick dot spence at freescale
| |dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36124
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/36124] conditional loop becomes infinite loop in -O2 (gcc 4.2 -> 4.3 regression)
2008-05-04 16:26 [Bug c/36124] New: conditional loop becomes infinite loop in -O2 (gcc 4.2 -> 4.3 regression) cyprien+gccbug at cypou dot net
` (9 preceding siblings ...)
2008-05-13 20:02 ` pinskia at gcc dot gnu dot org
@ 2008-05-13 21:14 ` scottwood at freescale dot com
10 siblings, 0 replies; 12+ messages in thread
From: scottwood at freescale dot com @ 2008-05-13 21:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from scottwood at freescale dot com 2008-05-13 21:13 -------
(In reply to comment #4)
> If your code invokes undefined behavior, how is gcc going
> to read your mind?
If GCC can tell that it is undefined behavior, then warning the user is more
useful than silently producing nasal demons, regardless of what might be in the
user's mind. "The spec allows us to do something stupid" doesn't mean "we
should do something stupid".
> Maybe the programmer meant to enter
> an infinite, so a warning isn't correct.
If it's undefined behavior, then too bad, right? I have a really hard time
seeing how one would derive such intent from the above code, though -- or
imagining what GCC is doing that made it think that generating the code it does
is a good idea.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36124
^ permalink raw reply [flat|nested] 12+ messages in thread