[Bug c++/61683] New: decltype-specifier not accepted as mem-initializer-id
bbi5291 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Jul 3 02:23:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61683
Bug ID: 61683
Summary: decltype-specifier not accepted as mem-initializer-id
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: bbi5291 at gmail dot com
$ cat main.cpp
struct A {};
A a;
struct B : A {
B(): decltype(a)() {}
};
int main() {}
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --program-suffix=-4.9.0
Thread model: posix
gcc version 4.9.0 (GCC)
$ g++-4.9.0 -std=c++11 main.cpp
main.cpp: In constructor ‘B::B()’:
main.cpp:4:10: error: expected identifier before ‘decltype’
B(): decltype(a)() {}
^
main.cpp:4:10: error: expected ‘{’ before ‘decltype’
--
This code should compile because the standard says that any class-or-decltype
that denotes a base class can be used in a mem-initializer-list.
clang accepts: http://coliru.stacked-crooked.com/a/b50333efbcab9d26
More information about the Gcc-bugs
mailing list