[Bug c++/58738] New: forward declaration of function inside function cause link problem with optimization

dushistov at mail dot ru gcc-bugzilla@gcc.gnu.org
Tue Oct 15 12:38:00 GMT 2013


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

            Bug ID: 58738
           Summary: forward declaration of function inside function cause
                    link problem with optimization
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dushistov at mail dot ru

Here source code of test case:
namespace {

int foo()
{
    int bar(void);
    return bar();
}

int bar() { return -1; }

}

int main(int argc, char* argv[])
{
    return foo();
}

With g++ -O0 -Wpedantic -ansi -Wall test.cpp it compiles fine, while
with the same options except s/-O0/-O2/g it gave:
undefined reference to `(anonymous namespace)::bar()'.

gcc 4.8.1/amd64



More information about the Gcc-bugs mailing list