https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89642
Bug ID: 89642 Summary: gcc rejects valid implicit typename context in cast Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: blitzrakete at gmail dot com Target Milestone: --- template <typename T> void f(T t) { static_cast<int(T::type)>(t); // gcc rejects, but this is well-formed } gcc rejects the above with: <source>: In function 'void f(T)': <source>:3:18: error: expected '>' before '(' token 3 | static_cast<int(T::type)>(t); | ^ But the code is well-formed, since the smallest enclosing type-id of `int(T::type)` is the type-id of the static_cast, which is a valid type-id-only context as per [temp.res]p5.