From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E792A3864A21; Tue, 6 Dec 2022 13:37:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E792A3864A21 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670333846; bh=8mGHll6OTwWNWiLruR4VIBp0qLLrCPFPXDLkzfaTIpg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=E+dJEvvYh9XKlgPQUPyrYcAJfOtkGftrXG6SpO7DwjgkNGo7Ow5SEbCjKtQ93NTyR qDl3JFdVj9cXWNW0LKlBgohn48TMYCgBf3ROSyIJRzPpP7jW4JCrtbuYAOH2jHRy+v qnJjtJ5kQib6WQMEW8ZN4GXbBffDrEBTrMln5xeI= From: "aaron at aaronballman dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/107980] va_start does not warn about an arbitrary number of arguments in C2x mode Date: Tue, 06 Dec 2022 13:37:25 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: diagnostic 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: Message-ID: In-Reply-To: References: 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 --- Comment #5 from Aaron Ballman --- (In reply to Andrew Pinski from comment #3) > I think we should warn but how to warn is going to have to special case t= he > macro I think. I was contemplating a perhaps terrible idea of adding some new builtins: ``` unsigned __builtin_va_opt_count(...); void __builtin_c23_va_start(va_list list, unsigned arg_count); ``` and then doing something along these lines in stdarg.h: ``` #if defined(__STDC_VERSION__) && __STDC_VERSION__ >=3D 202000L #define va_start(ap, ...) __builtin_c23_va_start(ap, __builtin_va_opt_count(__VA_OPT__)) #else ... #endif ``` but I've not put enough thought into it yet. WDYT about something along tho= se lines? (In reply to Andrew Pinski from comment #4) > (In reply to Andrew Pinski from comment #3) > > I think we should warn but how to warn is going to have to special case= the > > macro I think. >=20 > But saying that I do think it is valid C2X code if you take the C2X stand= ard > seperately from the older standards. I'm sad I noticed this after the NB comment period closed for the US NB bec= ause otherwise I'd leave a comment to make it a constraint violation to pass more than two arguments to the macro (or at least a recommended practice to diagnose). Because I agree with you that the letter of the standard makes t= his valid in C2x, but given that the extra arguments are not expanded or evalua= ted, there is no reason to accept more than two arguments in any C standard vers= ion.=