0

I found a few similar issues but none as simple as mine in that I have a template inside a Struct scope that is explicitly being specialised. Under MSVC this is fine and Clang> 6.0.1 but GCC reports errors for all versions.

Which compiler is correct as per the standard?

A minimal example of the issue: https://godbolt.org/z/1Mh8P7jh9

error: explicit specialization of 'TFoo' in class scope

struct Bar
{
    template<typename T>
    class TFoo
    {
        
    };

    // * GCC (ALL) 6.2 to 11.1 + trunk
    // error: explicit specialization in non-namespace scope 'struct Bar
    // error: too few template-parameter-lists
    // * Clang <= 6.0.1
    // error: explicit specialization of 'TFoo' in class scope
    template<>
    class TFoo<int>
    {
        int a;        
    };
};
Crog
  • 1,112
  • 8
  • 16
  • 1
    For reference: [Explicit specialization in non-namespace scope does not compile in GCC](https://stackoverflow.com/q/49707184/3309790) – songyuanyao Jun 02 '21 at 07:41
  • Fab, my search results on Stackoverflow didn't come up with this for whatever reason! Felt like a bug so good to know. – Crog Jun 02 '21 at 07:48

0 Answers0