From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4B4E5385BF83; Tue, 7 Apr 2020 08:23:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B4E5385BF83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1586247807; bh=BdiFw9T7TuOQ/hhwR3MEkjSk+krKqhtbsi22sItbR0s=; h=From:To:Subject:Date:From; b=q5txvE+meM5+4qLrgKy10mxNJPL4JB4OgATIPlgC7GygqSVf/C8BHahspJTb30qTX 6g5XsVE+DA7ogPYPY34d0jlsXnNkIAGBdj8NEimf3k3qqWH+ZlIsKZyiF2mH14qxAW 6slPgqnzJ12VyEN6yTURAnySmSgziCqhk5tIy5ek= From: "kndevl at outlook dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/94510] New: nullptr_t implicitly cast to zero twice in std::array Date: Tue, 07 Apr 2020 08:23:27 +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: kndevl at outlook 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: Tue, 07 Apr 2020 08:23:27 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94510 Bug ID: 94510 Summary: nullptr_t implicitly cast to zero twice in std::array Product: gcc Version: 9.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: kndevl at outlook dot com Target Milestone: --- `std::array arr{ nullptr, 0, 0 };` is expected to fail to compile similar to how `std::array arr{ nullptr, 0, 1 };` fails. What I inf= er is that if all elements are effectively zero, type conversions are not chec= ked. This makes sense if a variable of static storage duration is initialized to zero and std::array constructor can ignore the arguments in the initializer= if all arguments are implicitly zero.=20 Is there anything on the C++ standard that allows this optimization I am missing here? # This works fine, as expected `g++ -save-temps -c not-bug.cpp` > not-bug.cpp: In function =E2=80=98void test()=E2=80=99: > not-bug.cpp:4:43: error: cannot convert =E2=80=98std::nullptr_t=E2=80=99 = to =E2=80=98int=E2=80=99 in initialization > 4 | std::array arr{ nullptr, 0, 1 }; # This compiles fine, but this should error out `g++ -save-temps -c bug.cpp` I built the tip of gcc yesterday. It had the same bug. Any pointers on how I can go about debugging this?=20 - Does type checking happen during GENERIC stage? - How do I print the source string corresponding to a TREE struct?=