This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [3.4] New parser problem?


Richard Guenther wrote:
Hi!

Shouldnt the new parser be able to disambiguate the following code?
(I know 3.2 and 3.3 cannot)

template<class T>
struct Foo {
        Foo(T&);
        void operator()();
};

void foo()
{
        double d;
        Foo<double>(d)();
}
the *parser* does. It correctly considers the last line to be a declaration
of a function called d. further processing says 'but there's already a d'.

Think how hard it would be if the meaning of your program changed, by changing
an unrelated line of code!

or am I required by the standard to write
        (Foo<double>(d))();
here (EDG based intel compiler complains, too)?
yes.

Note that changing the constructor to take more or less arguments
disambiguates, too. I.e.
        Foo<double>()();
and
        Foo<double>(d, d)();
are parsed ok.
because those cannot be declarations.

nathan

--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
         The voices in my head said this was stupid too
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]