The following code comes from this StackOverflow Q&A (note this is not related to std::bitset, it's just a homegrown class to experiment with constexpr): http://stackoverflow.com/q/29871138/819272 #include <cstddef> template<std::size_t> class bitset; template<std::size_t N> constexpr bool operator==(const bitset<N>&, const bitset<N>&) noexcept; template<std::size_t N> class bitset { friend constexpr bool operator== <>(const bitset<N>&, const bitset<N>&) noexcept; //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ <-- error from this piece }; template<std::size_t N> constexpr bool operator==(const bitset<N>&, const bitset<N>&) noexcept { return true; } int main() {} The error I get with -std=c++11 on gcc 4.9.1 through gcc HEAD 6.0.0 20150501 is 'constexpr' is not allowed in declaration of friend template specialization The same code on older gcc version (4.6 through 4.8) gives a slightly different error 'inline' is not allowed in declaration of friend template specialization which seems to have been introduced in 2013 https://gcc.gnu.org/ml/gcc-patches/2013-03/msg01028.html Richard Smith's accepted answer on StackOverflow ( http://stackoverflow.com/a/29957648/819272 ) states that although constexpr functions are implicitly inline, an inline function does not imply the inline specifier. Therefore the above code should be valid.
Mine.
Author: paolo Date: Mon Jun 29 22:02:08 2015 New Revision: 225148 URL: https://gcc.gnu.org/viewcvs?rev=225148&root=gcc&view=rev Log: /cp 2015-06-29 Paolo Carlini <paolo.carlini@oracle.com> PR c++/65977 * decl.c (grokfndecl): Allow constexpr declarations of friend template specializations. /testsuite 2015-06-29 Paolo Carlini <paolo.carlini@oracle.com> PR c++/65977 * g++.dg/cpp0x/constexpr-friend-3.C: New. * g++.dg/cpp0x/constexpr-friend-2.C: Adjust. Added: trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-friend-3.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/decl.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-friend-2.C
Fixed.
Ping to get this merged into the upcoming 5.4.