https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65579

            Bug ID: 65579
           Summary: [C++11] gcc requires definition of a static constexpr
                    member even though it is not odr-used
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kariya_mitsuru at hotmail dot com

Created attachment 35143
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35143&action=edit
g++ -v

The sample code below should be compiled and linked successfully but it causes
a linkage error.

============== sample code ==============
template <typename>
struct S {
    int i;
};

struct T {
    static constexpr S<int> s{1};
};

int main()
{
    return T::s.i;
}
============== sample code ==============
cf. http://melpon.org/wandbox/permlink/JFgGdscpiHVEJpdb


I think that the T::s is not odr-used.


Note that it is compiled and linked successfully if S is not a template.

============== sample code ==============
struct S {
    int i;
};

struct T {
    static constexpr S s{1};
};

int main()
{
    return T::s.i;
}
============== sample code ==============
cf. http://melpon.org/wandbox/permlink/bvH2k7pW8WQSXQmN

Reply via email to