[llvm-bugs] [Bug 46788] New: Anonymous struct members initialized with designated initializers

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jul 21 06:57:39 PDT 2020


            Bug ID: 46788
           Summary: Anonymous struct members initialized with designated
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: piovezan.fpi at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

The following code fails to compile: 

struct State {
  struct {
    int anon_struct_member;

template <int VAL> void init() {
  State mystruct = {
      .anon_struct_member = VAL,

void foo() { init<1>(); }

The error message:

error: field designator (null) does not refer to any field in type 'State'


Anonymous struct members is an extension that doesn't seem to play well with
template parameters. If you declare a local variable `constexpr auto val_local
= VAL` and use that instead in the struct initializer, the code compiles.

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/20200721/277a5f58/attachment.html>

More information about the llvm-bugs mailing list