public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/31727]  New: Functions with non-local gotos are considered not to have side effects
@ 2007-04-27 10:55 rakdver at gcc dot gnu dot org
  2007-04-27 11:04 ` [Bug tree-optimization/31727] " rguenth at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: rakdver at gcc dot gnu dot org @ 2007-04-27 10:55 UTC (permalink / raw)
  To: gcc-bugs

In the following testcase with -O1, dce removes the bla call, thus
making the otherwise infinite loop terminate:

static void bla(void *label)
{
  goto *label;
}

int main (void)
{
l1:
  bla (&&l1);

  return 0;
}


-- 
           Summary: Functions with non-local gotos are considered not to
                    have side effects
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rakdver at gcc dot gnu dot org


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


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

* [Bug tree-optimization/31727] Functions with non-local gotos are considered not to have side effects
  2007-04-27 10:55 [Bug tree-optimization/31727] New: Functions with non-local gotos are considered not to have side effects rakdver at gcc dot gnu dot org
@ 2007-04-27 11:04 ` rguenth at gcc dot gnu dot org
  2007-04-27 23:36 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-04-27 11:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2007-04-27 12:04 -------
I think this is ipa-pure-const again:

Function found to be const: bla
Function found to be const: main

and DCE removes pure/const function calls.  (We should also not CSE such
calls)


-- 


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


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

* [Bug tree-optimization/31727] Functions with non-local gotos are considered not to have side effects
  2007-04-27 10:55 [Bug tree-optimization/31727] New: Functions with non-local gotos are considered not to have side effects rakdver at gcc dot gnu dot org
  2007-04-27 11:04 ` [Bug tree-optimization/31727] " rguenth at gcc dot gnu dot org
@ 2007-04-27 23:36 ` pinskia at gcc dot gnu dot org
  2007-04-27 23:37 ` pinskia at gcc dot gnu dot org
  2007-04-27 23:40 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-04-27 23:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2007-04-28 00:36 -------
This code is undefined
Take a look at the manual:
http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Labels-as-Values.html

You may not use this mechanism to jump to code in a different function. If you
do that, totally unpredictable things will happen. The best way to avoid this
is to store the label address only in automatic variables and never pass it as
an argument. 

There is nothing special about this code, except it is undefined :).


-- 

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=31727


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

* [Bug tree-optimization/31727] Functions with non-local gotos are considered not to have side effects
  2007-04-27 10:55 [Bug tree-optimization/31727] New: Functions with non-local gotos are considered not to have side effects rakdver at gcc dot gnu dot org
  2007-04-27 11:04 ` [Bug tree-optimization/31727] " rguenth at gcc dot gnu dot org
  2007-04-27 23:36 ` pinskia at gcc dot gnu dot org
@ 2007-04-27 23:37 ` pinskia at gcc dot gnu dot org
  2007-04-27 23:40 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-04-27 23:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2007-04-28 00:37 -------
Oh and this goto is considered not a non-local goto, it is just considered a
computed goto.  A non-local goto is only with nested functions.  Like:
int main (void)
{
__label__ l1;
void bla(void)
{
  goto l1;
}
l1:
 bla();

  return 0;
}


Which we handle correctly by the way :).


-- 


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


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

* [Bug tree-optimization/31727] Functions with non-local gotos are considered not to have side effects
  2007-04-27 10:55 [Bug tree-optimization/31727] New: Functions with non-local gotos are considered not to have side effects rakdver at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-04-27 23:37 ` pinskia at gcc dot gnu dot org
@ 2007-04-27 23:40 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-04-27 23:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2007-04-28 00:40 -------
By the way non local gotos are documented at:
http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Nested-Functions.html


I really guess nobody actually reads the documentation (yes we can improve it
but even then people still won't read it :) ).

I don't know how to fix that issue except keep on pointing out in our
documentation about where stuff is documented.


-- 


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


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

end of thread, other threads:[~2007-04-27 23:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-27 10:55 [Bug tree-optimization/31727] New: Functions with non-local gotos are considered not to have side effects rakdver at gcc dot gnu dot org
2007-04-27 11:04 ` [Bug tree-optimization/31727] " rguenth at gcc dot gnu dot org
2007-04-27 23:36 ` pinskia at gcc dot gnu dot org
2007-04-27 23:37 ` pinskia at gcc dot gnu dot org
2007-04-27 23:40 ` 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).