From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 94074 invoked by alias); 17 May 2015 17:53:22 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 94023 invoked by uid 48); 17 May 2015 17:53:09 -0000 From: "Casey at Carter dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/66184] New: Rejection of partial specialization of a variable template in a non-global namespace Date: Sun, 17 May 2015 17:53:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 6.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: Casey at Carter dot net X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-05/txt/msg01321.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D66184 Bug ID: 66184 Summary: Rejection of partial specialization of a variable template in a non-global namespace Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: Casey at Carter dot net Target Milestone: --- Created attachment 35558 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D35558&action=3Dedit testcase.cpp Both 5.1.0 on Wandbox and 6.0 r223061 reject this program: namespace foo { template constexpr bool same =3D false; template <> constexpr bool same =3D true; template constexpr bool same =3D true; static_assert(same, ""); static_assert(!same, ""); } int main() {} with error message: bug2.cpp:4:35: error: specialization of =E2=80=98template con= stexpr const bool foo::same< , >=E2=80= =99 in different namespace [-fpermissive] template constexpr bool same =3D true; ^ bug2.cpp:2:40: error: from definition of =E2=80=98template = constexpr const bool foo::same< , >= =E2=80=99 [-fpermissive] template constexpr bool same =3D false; ^ The full specialization of same is accepted regardless of namesp= ace. Both versions compile the program correctly if "same" is in the global namespace. >>From gcc-bugs-return-486482-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun May 17 18:20:48 2015 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 125682 invoked by alias); 17 May 2015 18:20:48 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 125628 invoked by uid 48); 17 May 2015 18:20:44 -0000 From: "harald at gigawatt dot nl" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/65942] [5/6 Regression] [C++14] cannot use std::function as comparator in algorithms Date: Sun, 17 May 2015 18:20:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: harald at gigawatt dot nl X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: redi at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-05/txt/msg01322.txt.bz2 Content-length: 1918 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65942 Harald van Dijk changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |harald at gigawatt dot nl --- Comment #11 from Harald van Dijk --- GCC and clang are instantiating constexpr function bodies when only the signature should be checked (when they appear in unevaluated expressions). A shorter example program: template constexpr int f(T t) { return t; } int main() { sizeof(f("")); } This is rejected by GCC and clang, but accepted by Intel and Sun C++. As far as I can tell, it should be accepted. f is used in a context where a definition of f is not required, so f should not be instantiated. f is used in a way that involves overload resolution, so a declaration of f is instantiated, but that declaration does not contain the error that GCC and clang report. GCC and clang accept it when constexpr is removed. It's made worse by the fact that it happens even in SFINAE contexts, where such an error should at worst lead to a substitution failure: template constexpr int f(T t) { return t; } template void g(T) { } void g(...) { } int main() { g(""); } Here, either the use of f(T()) is an error, so overload resolution should discard the first g overload, and the program should be accepted, or the use of f(T()) is valid, so overload resolution should prefer the first g overload, and the program should still be accepted. But even this is rejected by GCC and clang. Even if this gets worked around in libstdc++, it's probably worth tracking this as a C++ frontend bug as well. The programs in my comment here are accepted by G++ 4.5.4 (with -std=c++0x), and rejected by 4.6.4 and later.