int
main ()
{
  main();
}

Compiling this program at different optimisation levels gives different
results. Levels O3 and Os appear to be broken (with GCC 4.1.1).

$ g++ t.cxx -c -ansi -pedantic -O0
t.cxx: In function ‘int main()’:
t.cxx:4: error: ISO C++ forbids taking address of function ‘::main’

$ g++ t.cxx -c -ansi -pedantic -O1
t.cxx: In function ‘int main()’:
t.cxx:4: error: ISO C++ forbids taking address of function ‘::main’

$ g++ t.cxx -c -ansi -pedantic -O2
t.cxx: In function ‘int main()’:
t.cxx:4: error: ISO C++ forbids taking address of function ‘::main’

$ g++ t.cxx -c -ansi -pedantic -O3

$ g++ t.cxx -c -ansi -pedantic -Os


-- 
           Summary: Calling main allowed at O3 and Os
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: andrew dot stubbs at st dot com


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

Reply via email to