[llvm-bugs] [Bug 44406] New: Const is not compile-time constant

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Dec 29 22:24:29 PST 2019


            Bug ID: 44406
           Summary: Const is not compile-time constant
           Product: clang
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mcccs at gmx.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

const int a = 32;

typedef struct {
    char c[a];
} d;

GCC: error: variably modified 'c' at file scope
CompCert: error: size of array is not a compile-time constant

Clang -Wextra: *compiles*
Clang -pedantic: warning: variable length array folded to constant array as an
extension [-Wgnu-folding-constant]

The problem? This is not a GNU extension. Either the warning is wrong or the
code that shouldn't compile compiles.

Weirdly, MSVC has the same behavior as Clang but does not issue a warning.

Once it is confirmed, I'll file an Apple bug report, because an Xcode header,
Security.framework/Headers/Authorization.h suffers from this issue and can only
be compiled with Clang (so when this bug is patched don't tell me that I broke
Apple's code :) )

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191230/5a2b604c/attachment.html>

More information about the llvm-bugs mailing list