http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58047
Bug ID: 58047
Summary: parse error with typedef introduced from base class
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: roshan.shariff at gmail dot com
Created attachment 30585
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30585&action=edit
Test case exhibiting parse error
Trying to compile the attached code with g++ 4.8.1 gives an error. The code
compiles and works fine with clang.
template <int N>
struct print_arg {
void print () { std::cout << N << '\n'; }
};
struct const_holder {
static constexpr int CONSTANT = 42;
};
template <typename T>
struct identity {
using type = T;
};
template <class T>
struct test_case : public identity<T> {
using typename identity<T>::type;
print_arg<type::CONSTANT> printer; // <- parse error
};
int main () {
// Should print 42
test_case<const_holder>().printer.print();
}
The attached file contains two variants of the above code that do work fine.
Trying to compile it produces the following error message:
$ g++ -std=c++11 gccbug.cpp -o gccbug
gccbug.cpp:31:3: error: parse error in template argument list
print_arg<type::CONSTANT> printer;
^
gccbug.cpp: In instantiation of 'struct test_case<const_holder>':
gccbug.cpp:46:27: required from here
gccbug.cpp:31:29: error: expected primary-expression
print_arg<type::CONSTANT> printer;
^
gccbug.cpp: In function 'int main()':
gccbug.cpp:46:29: error: 'struct test_case<const_holder>' has no member named
'printer'
test_case<const_holder>().printer.print();