[Bug c++/55280] Compiler error: Class definition is recognized as function declaration

2012-11-12 Thread guangmuzhu at gmail dot com


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



--- Comment #3 from Guangmu Zhu guangmuzhu at gmail dot com 2012-11-12 
09:22:01 UTC ---

(In reply to comment #2)

 As Andrew said, this is not a bug, see

 http://en.wikipedia.org/wiki/Most_vexing_parse

 

 You can force it to be parsed as a variable declaration with A a((B()))



I got it. Thanks a lot!


[Bug c++/55280] New: Compiler error: Class definition is recognized as function declaration

2012-11-11 Thread guangmuzhu at gmail dot com


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



 Bug #: 55280

   Summary: Compiler error: Class definition is recognized as

function declaration

Classification: Unclassified

   Product: gcc

   Version: 4.7.2

Status: UNCONFIRMED

  Severity: normal

  Priority: P3

 Component: c++

AssignedTo: unassig...@gcc.gnu.org

ReportedBy: guangmu...@gmail.com





A and B are both class. If a object is defined by A a(B());, compiler reports

a is none-class type A(B (*)()).

I guess g++ translates it to B temp(); A a(b);. If a is defined by A

a(B(argument));, it's OK. But unfortunately, default constructor is not

allowed to be used like B temp();, temp is declared as a function.

ps: vs 2008 doesn't have the problem