Parse error
Matt Austern
austern@apple.com
Mon Jul 22 18:04:00 GMT 2002
On Monday, July 22, 2002, at 01:35 PM, Andrew Pinski wrote:
> I think this is a know problem, you can work around it via putting
> pareneses around my_class(foo())
>
> Thanks,
> Andrew Pinski
> PS the following compiles with 3.3 built from the sources of last
> night:
>
> struct my_class {
> my_class(int);
> void abcd();
> };
>
> int foo();
>
> void bar() {
> (my_class(foo())).abcd();
> }
Oh, I know that there are workarounds! Another workaround,
of course, is using an explicit temporary. That's not really what
I'm interested in. I'd like to know if (1) there are any arguments
that the behavior of the 3.1 compiler is correct; and (2) if not,
whether this is a known bug.
My reading of 6.8 [stmt.ambig] is that this behavior is not
correct, that ambiguity resolution only comes into play if a
statement could be interpreted either as a syntactically valid
expression-statement or as a syntactically valid declaration,
and that the compiler is not allowed to reject something that
could be interpreted as a valid expression-statement just
because the first part of it could be the first part of a declaration.
--Matt
More information about the Gcc
mailing list