Parsing issue: Instance reinterpreted as function-pointer something
Bug #799066 reported by
Hendrik Lönngren
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
ProcVersionSign
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
Changed in gcc-4.4 (Ubuntu): | |
status: | New → Invalid |
To post a comment you must log in.
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.