From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8079D383F874; Mon, 11 May 2020 17:50:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8079D383F874 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1589219404; bh=fgQcqY1u3ve32isN7qrnhzovnQtTY7G/08c9dreK2h4=; h=From:To:Subject:Date:From; b=HjcfHaWEG9VKGa8xL9vZQcW02hvhRGuUU+STaZjKT1o7L/FsvNMh56cHvhl09zM34 U3JclIW1RZ2ie18L6/2UjLxUXZms79iUUnale7/3yUcG3raj0bx3ZlpG2c4+Ec9ZmK soNke4545nydl/2R+DY1c311Oubuy0FglSeOc5Wc= From: "ojman101 at protonmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/95066] New: [C++ 20] Incorrect valid compilation with a conditional explicit Date: Mon, 11 May 2020 17:50:04 +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: 9.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ojman101 at protonmail dot com 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 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-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 May 2020 17:50:04 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95066 Bug ID: 95066 Summary: [C++ 20] Incorrect valid compilation with a conditional explicit Product: gcc Version: 9.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ojman101 at protonmail dot com Target Milestone: --- The code below is invalid C++, the line "Foo b =3D a;" should fail to compile as implicitly casting is made illegal by the conditional explicit u= sing the "IsSafelyCastable" predicate. ---------------------------------------------------------------- #include template class IsSafelyCastable : public std::false_type {}; template <> class IsSafelyCastable : public std::true_type {}; template struct Foo { template explicit(!IsSafelyCastable::value) operator Foo(); }; template template Foo::operator Foo() { return {}; } int main() { Foo a; Foo b =3D a; } ---------------------------------------------------------------- Clang 10 correctly evaluates the explicit condition to be true and blocks t= he implicit cast. However, GCC 9.3.0 successfully compiles without any errors.= I believe this to be a GCC bug as subtle changes can make GCC produce the cor= rect error. For example, moving the definition of the function to be inline with= the declaration.=