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

             Bug #: 50359
           Summary: poor error message for an undeclared identifier in
                    constructor
    Classification: Unclassified
           Product: gcc
           Version: 4.5.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: rui.mac...@gmail.com


Consider the following code:

<code>
struct Foo
{
public:
        Foo(int);
};


Foo::Foo(undeclared)
{
}


int main(void)
{
        Foo f(1);

        return 0;
}
</code>

When compiling the above code, the following error message is shown:

<message>
main.c++:8:9: error: expected constructor, destructor, or type conversion
before ‘(’ token
</message>

Although the error consists of a poorly defined parameter, which may actually
be a simple typo, g++ complains instead about the code which was parsed before
the '(' token, which is actually (at least to the best of my knowledge)
correct.

It would be nice if GCC informed the user about an undeclared identifier
instead of throwing a cryptic message regarding the portion of the code which
is valid.

Reply via email to