Skip to content

Clang and GCC behave inconsistently on constant parameters #111622

@huhu233

Description

@huhu233
#include <stdarg.h>
//#define va_arg(v, l) __builtin_va_arg(v, l)

void test(const va_list *a)
{
  va_arg(*a, unsigned long);
}

LLVM failed, as shown
https://godbolt.org/z/GTo7zfabM

<source>:6:3: error: read-only variable is not assignable
    6 |   va_arg(*a, unsigned long);
      |   ^      ~~
/opt/compiler-explorer/clang-trunk-20241008/lib/clang/20/include/__stdarg_va_arg.h:20:26: note: expanded from macro 'va_arg'
   20 | #define va_arg(ap, type) __builtin_va_arg(ap, type)
      |                          ^                ~~
1 error generated.
Compiler returned: 1

GCC pass,
https://godbolt.org/z/Mr5WE5jf7

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"diverges-from:gccDoes the clang frontend diverge from gcc on this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions