Skip to content

clang-cl disallows C11 convenience macro static_assert in the function scope #48248

@llvmbot

Description

@llvmbot
Bugzilla Link 48904
Resolution FIXED
Resolved on Jan 29, 2021 22:22
Version unspecified
OS Windows NT
Blocks #48246
Attachments reduced test-case
Reporter LLVM Bugzilla Contributor
CC @nico,@zygoloid,@tstellar
Fixed by commit(s) 764a7a2 8c5d184

Extended Description

The clang-cl compiler disallows C11 convenience macro static_assert in the function scope. It does allow static_assert in the file scope.

This problem is also reported in ionescu007/minlzma#1.

Here is a reduced test-case:

C:\src\build>clang-cl --version
clang version 12.0.0 (https://github.com/llvm/llvm-project/ 6de4865)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\src\chromium\src\third_party\llvm-build\Release+Asserts\bin

C:\src\build>type static-assert.c
#include <assert.h>

_Static_assert(1 == 1, "");
static_assert(1 == 1, "");

void Foo(void) {
_Static_assert(1 == 1, "");
static_assert(1 == 1, "");
}
C:\src\build>clang-cl /s static-assert.c
clang-cl: error: no such file or directory: '/s'

C:\src\aom.1\build.clang-cl>clang-cl /c static-assert.c
static-assert.c(8,3): error: expected expression
static_assert(1 == 1, "");
^
1 error generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclangClang issues not falling into any other category

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions