[llvm-bugs] [Bug 45157] New: Clang and gcc disagree on whether a `static const struct` is a compile-time constant

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Mar 9 11:00:10 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45157

            Bug ID: 45157
           Summary: Clang and gcc disagree on whether a `static const
                    struct` is a compile-time constant
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ndesaulniers at google.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    efriedma at quicinc.com, erik.pilkington at gmail.com,
                    isanbard at gmail.com, jyknight at google.com,
                    llozano at chromium.org, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk, srhines at google.com
            Blocks: 4068

```
struct foo {};
struct bar{
    struct foo foo;
};

static const struct foo my_foo = {};
static const struct bar my_bar = {
    .foo = my_foo,
};
```
Clang produces:
```
<source>:8:12: error: initializer element is not a compile-time constant

    .foo = my_foo,

           ^~~~~~
```
GCC has no error.

A recent CI run on the Linux kernel failed for Clang on this patch:
https://cgit.freedesktop.org/~jani/drm/commit/?h=device-info-inheritance-v3&id=329fec687c7310f3a68ae1c6fd3638274484f149


Referenced Bugs:

https://bugs.llvm.org/show_bug.cgi?id=4068
[Bug 4068] [Meta] Compiling the Linux kernel with clang
-- 
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/20200309/b29be063/attachment.html>


More information about the llvm-bugs mailing list