Parsing issue: Instance reinterpreted as function-pointer something

Bug #799066 reported by Hendrik Lönngren
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc-4.4 (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Binary package hint: gcc-4.4

When compiling the attached code with

g++ -c -o test.o test.cpp

I get the following error:

test.cpp: In function ‘int main()’:
test.cpp:15: error: request for member ‘dummy’ in ‘b’, which is of non-class type ‘B(A (*)())’

Actually I don’t even think that is a type.

ProblemType: Bug
DistroRelease: Ubuntu 10.10
Package: g++-4.4 4.4.4-14ubuntu5
ProcVersionSignature: Ubuntu 2.6.35-28.50-generic 2.6.35.11
Uname: Linux 2.6.35-28-generic i686
Architecture: i386
Date: Sat Jun 18 08:54:49 2011
ProcEnviron:
 LANGUAGE=eo
 PATH=(custom, user)
 LANG=de_DE.UTF-8
 SHELL=/bin/bash
SourcePackage: gcc-4.4

Revision history for this message
Hendrik Lönngren (hendrik0) wrote :
Changed in gcc-4.4 (Ubuntu):
status: New → Invalid
Revision history for this message
Hendrik Lönngren (hendrik0) wrote :

On further thought, I see that g++ allows "A()" as a shortcut for "A(*)()", so it confuses "B b(A());" with a function declaration. As this might be as designed, I am closing this bug.
But still, I think that this code should be perfectly legal. Also, the compiler error would be much clearer if it said "B (*)(A (*)())" instead of "B(A (*)())". Overall, allowing that shortcut doesn’t seems like a good idea to me.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.