Bug 78274 - [DR 374] Rejected specialization in different namespace
Summary: [DR 374] Rejected specialization in different namespace
Status: RESOLVED DUPLICATE of bug 56480
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 6.1.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2016-11-09 11:37 UTC by Jakub Jelinek
Modified: 2017-01-10 22:11 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-11-09 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2016-11-09 11:37:50 UTC
I've noticed that clang++ accepts, but g++ rejects:
namespace std { template<typename T> struct tuple_size; }
struct A { int x, y, z; };
template<> struct std::tuple_size<A> { static const int value = 3; };
constexpr int a = std::tuple_size<A>::value;
test.C:3:24: error: specialization of ‘template<class T> struct std::tuple_size’ in different namespace [-fpermissive]
 template<> struct std::tuple_size<A> { static const int value = 3; };
                        ^~~~~~~~~~~~~
test.C:1:45: error:   from definition of ‘template<class T> struct std::tuple_size’ [-fpermissive]
 namespace std { template<typename T> struct tuple_size; }
                                             ^~~~~~~~~~
Is that a g++ or clang++ bug?
Comment 1 Jonathan Wakely 2016-11-09 17:14:56 UTC
It's invalid in C++98 but valid in C++11, so we should accept it.

The change was done by
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3064.pdf
to fix http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#374
Comment 2 Jason Merrill 2017-01-10 22:11:44 UTC
Fixed.

*** This bug has been marked as a duplicate of bug 56480 ***