Skip to content

Compilation error with "alignas" #144321

Closed
Closed
@8ss-boop

Description

@8ss-boop
#include <stdint.h>
#include <stdarg.h>


void compute_values(int count, ...) {
    static _Atomic(int) shared_value = 0;
    va_list args;
    va_start(args, count);

    int temp[16] = {0};

    for (int i = 0; i < count && i < 16; i++) {
        int val = va_arg(args, int);
        temp[i] = (val > 0)
            ? ((val & 1) ? (temp[i ? i - 1 : 0] + val) : (shared_value += val))
            : ((alignas(16) int){ val * -1 });
    }
}

Compilation error:

<source>:16:17: error: expected expression
   16 |             : ((alignas(16) int){ val * -1 });
      |                 ^
1 error generated.
Compiler returned: 1

https://godbolt.org/z/478dvGehr

Is this a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    c23questionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions