public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/107980] New: va_start incorrectly accepts an arbitrary number of arguments in C2x
@ 2022-12-05 20:46 aaron at aaronballman dot com
  2022-12-05 20:57 ` [Bug c/107980] " pinskia at gcc dot gnu.org
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: aaron at aaronballman dot com @ 2022-12-05 20:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107980

            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 <stdarg.h>

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, which 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.

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2022-12-07 18:29 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-05 20:46 [Bug c/107980] New: va_start incorrectly accepts an arbitrary number of arguments in C2x aaron at aaronballman dot com
2022-12-05 20:57 ` [Bug c/107980] " pinskia at gcc dot gnu.org
2022-12-05 21:04 ` aaron at aaronballman dot com
2022-12-05 21:10 ` [Bug c/107980] va_start does not warn about an arbitrary number of arguments in C2x mode pinskia at gcc dot gnu.org
2022-12-05 21:17 ` pinskia at gcc dot gnu.org
2022-12-06 13:37 ` aaron at aaronballman dot com
2022-12-06 13:44 ` pinskia at gcc dot gnu.org
2022-12-06 13:51 ` jakub at gcc dot gnu.org
2022-12-06 14:04 ` aaron at aaronballman dot com
2022-12-06 15:42 ` aaron at aaronballman dot com
2022-12-06 15:46 ` jakub at gcc dot gnu.org
2022-12-06 16:13 ` aaron at aaronballman dot com
2022-12-07  0:55 ` joseph at codesourcery dot com
2022-12-07 14:57 ` jakub at gcc dot gnu.org
2022-12-07 15:00 ` aaron at aaronballman dot com
2022-12-07 15:38 ` pinskia at gcc dot gnu.org
2022-12-07 16:42 ` aaron at aaronballman dot com
2022-12-07 18:29 ` joseph at codesourcery dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).