From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DED55389838A; Mon, 5 Dec 2022 20:46:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DED55389838A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670273170; bh=jvDchsyyM6T1PXYz8ArvAPL4rxVh8P3A4ZyK+CuOKss=; h=From:To:Subject:Date:From; b=kXtKwdHRiQLQ6mneuIr99vQzHflb/9EMG9m9FE8qthrwErrnNKSsebbxv8wGOxWEG MervrMIL1rwCyG7VLJJ6L8B4P6ojqVfYms6CT+KrprpSpDLMQMklKUnxyexTrxuXCx YbTFYuwprJkQ6uPVE2k+MxSxzWTt81FwwZ/wThig= From: "aaron at aaronballman dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/107980] New: va_start incorrectly accepts an arbitrary number of arguments in C2x Date: Mon, 05 Dec 2022 20:46:10 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: aaron at aaronballman 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107980 Bug ID: 107980 Summary: va_start incorrectly accepts an arbitrary number of arguments in C2x Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: aaron at aaronballman dot com Target Milestone: --- GCC implemented WG14 N2975 which relaxes the requirements for va_start. However, there's a diagnostic missing for it when the user passes more than= two arguments: ``` #include void func(int i, ...) { va_list va; va_start(va, i, 23, 4); va_end(va); } ``` is silently accepted by GCC even with -Wall and -pedantic. I noticed this when I was working on the Clang implementation of N2975. I noticed that GCC has not changed the definition of __builtin_va_start, whic= h I think is a good approach (keeping builtin interfaces stable between compiler and language versions is a nicety). I was considering adding `__builtin_c23_va_start` to Clang with a signature that accepts `...` so I = can diagnose this case, but I think that will run afoul of 7.16.1.4p4 "Any additional arguments are not used by the macro and will not be expanded or evaluated for any reason." without some heroics, so I'm not certain how/if Clang will address this.=