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

            Bug ID: 48745
           Summary: error: initializer element is not a compile-time
                    constant for valid code
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

For the following code:
struct wss {
  unsigned int  count;
  unsigned char _have_ct  : 1  ;
};
struct capab {
  struct wss _wss;
  unsigned char _have_type;
};
struct node {
  struct capab _capab;
};
struct node nd = {
    ._capab = {
      ._have_type = 1,
    },
    ._capab._wss.count = 1, // ERROR!
};

Clang gives error:
clang -emit-llvm test.c -c
error: initializer element is not a compile-time constant
1 error generated.

Code appears to be valid according to struct initialization rules, and gcc
gives no error:
gcc -c test.c
<No error>

Also, error message doesn't show error location in the code.

Versions:
clang --version
clang version 12.0.0 (https://github.com/llvm/llvm-project
f4f158b2f89e16ee7068d6292d2d46457d6932bb)
Target: x86_64-unknown-linux-gnu
Thread model: posix
gcc --version
gcc (GCC) 8.3.1 20190507 (Red Hat 8.3.1-4)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to