Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22453

Forward-declaration of enum member of template-specialization - fails with GCC

$
0
0

I know that, generally, we can forward-declare enums in C++11.

So, why does this:

enum kind_t { kind1, kind2 };template <kind_t Kind> struct foo {};template <> struct foo<kind1> {    enum named : int;};enum foo<kind1>::named : int {    named1 = 123,    named2 = 456,};

fail to compile with GCC (12.1)? The error is (Godbolt):

<source>:9:6: error: cannot add an enumerator list to a template instantiation    9 | enum foo<kind1>::named : int {      |      ^~~~~~~~~~ASM generation compiler returned: 1<source>:9:6: error: cannot add an enumerator list to a template instantiation    9 | enum foo<kind1>::named : int {      |      ^~~~~~~~~~

This seems to compile fine with clang++ 14.0...


Viewing all articles
Browse latest Browse all 22453

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>