From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 071C9384B0C7; Mon, 20 Jun 2022 14:01:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 071C9384B0C7 From: "goldstein.w.n at gmail dot com" To: glibc-bugs@sourceware.org Subject: [Bug string/29265] New: mbstowcs with NULL dst throws an incorrect warning (glibc == 2.35, gcc=12.0.1) Date: Mon, 20 Jun 2022 14:01:07 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: string X-Bugzilla-Version: 2.35 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: goldstein.w.n at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot 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://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: glibc-bugs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jun 2022 14:01:08 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D29265 Bug ID: 29265 Summary: mbstowcs with NULL dst throws an incorrect warning (glibc =3D=3D 2.35, gcc=3D12.0.1) Product: glibc Version: 2.35 Status: UNCONFIRMED Severity: normal Priority: P2 Component: string Assignee: unassigned at sourceware dot org Reporter: goldstein.w.n at gmail dot com Target Milestone: --- For example building binutils HEAD get the following warning: ``` In file included from /usr/include/features.h:486, from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33, from /usr/include/stdio.h:27, from as.h:42, from read.c:33: In function =E2=80=98mbstowcs=E2=80=99, inlined from =E2=80=98read_symbol_name=E2=80=99 at read.c:1670:11: /usr/include/x86_64-linux-gnu/bits/stdlib.h:115:10: error: argument 1 is nu= ll but the corresponding size argument 3 value is [128, 9223372036854775807] [-Werror=3Dnonnull] 115 | return __glibc_fortify_n (mbstowcs, __len, sizeof (wchar_t), | ^~~~~~~~~~~~~~~~~ In file included from /usr/include/stdlib.h:1027, from as.h:44: /usr/include/x86_64-linux-gnu/bits/stdlib.h: In function =E2=80=98read_symb= ol_name=E2=80=99: /usr/include/x86_64-linux-gnu/bits/stdlib.h:95:15: note: in a call to funct= ion =E2=80=98__mbstowcs_chk=E2=80=99 declared with attribute =E2=80=98access (r= ead_only, 2)=E2=80=99 95 | extern size_t __mbstowcs_chk (wchar_t *__restrict __dst, ``` Which is from: https://sourceware.org/git/?p=3Dbinutils-gdb.git;a=3Dblob;f=3Dgas/read.c;h= =3Dc6ce0345892284a48e5280ebb9cca111fab975f4;hb=3DHEAD#l1670 ``` 1670: if (mbstowcs (NULL, name, len) =3D=3D (size_t) -1) ``` `mbstowcs` supports a NULL destination: https://en.cppreference.com/w/cpp/string/multibyte/mbstowcs#:~:text=3DPOSIX= %20specifies%20a%20common%20extension%3A%20if%20dst%20is%20a%20null%20point= er%2C%20this%20function%20returns%20the%20number%20of%20wide%20characters%2= 0that%20would%20be%20written%20to%20dst%2C%20if%20converted.%20Similar%20be= havior%20is%20standard%20for%20std%3A%3Ambsrtowcs. so that seems like a bug in the GLIBC attributes of `mbstowcs`. --=20 You are receiving this mail because: You are on the CC list for the bug.=