From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 103273857C6B; Wed, 30 Sep 2020 10:57:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 103273857C6B From: "dimitri.gorokhovik at free dot fr" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/97253] New: [c++20] last character not shown when printing out std::array via -Wunused-local-typedefs Date: Wed, 30 Sep 2020 10:57:03 +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: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dimitri.gorokhovik at free dot fr 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: Wed, 30 Sep 2020 10:57:04 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97253 Bug ID: 97253 Summary: [c++20] last character not shown when printing out std::array via -Wunused-local-typedefs Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: dimitri.gorokhovik at free dot fr Target Milestone: --- The following code: #include #include template struct s { constexpr static auto m =3D M; }; int main () { constexpr auto s1 =3D s { 'a', 'b', 'c', 'd' }> {}; constexpr auto s2 =3D s { 'a', 'b', 'c', 'd' }> = {};=20=20 using _1 =3D decltype (s1); using _2 =3D decltype (s2);=20=20=20=20 for (auto i : s1.m) printf ("%c", i); printf ("\n"); return 0; }; when built as: g++ -std=3Dc++20 -Wunused-local-typedefs -o bug-7 bug-7.cpp && ./bug-7 produces the following warnings: bug-7.cpp: In function =E2=80=98int main()=E2=80=99: bug-7.cpp:11:9: warning: typedef =E2=80=98using _1 =3D const struct s{"abc"}>=E2=80=99 locally defined but not used [-Wunused-local-typedefs] 11 | using _1 =3D decltype (s1); | ^~ bug-7.cpp:12:9: warning: typedef =E2=80=98using _2 =3D const struct s{std::__array_traits::_Type{97, 98, 99, 100}}>=E2=80=99 local= ly defined but not used [-Wunused-local-typedefs] 12 | using _2 =3D decltype (s2); | ^~ When it is run, the output is: abcd I.e., when the warning displays the contents of the literal of the type std::array , it presents it as a character string ("abc") in which the last character is missing ('d' in this example). This doesn't happen when t= he array type doesn't allow to show it as char string -- all array elements are shown. Running the binary confirms that the array literal actually contains the non-shown character. g++ (GCC) 11.0.0 20200924 (experimental)=