[Bug 264288] llvm miscompiles the extension ({ ... })

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 27 May 2022 14:32:23 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=264288

            Bug ID: 264288
           Summary: llvm miscompiles the extension ({ ... })
           Product: Base System
           Version: 13.0-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: andrew.cagney@gmail.com

Given:


typedef const struct where {
        const char *func;
        const char *file;
        long line;
} *where_t;

and:

struct connection_filter {
        /* filters */
        enum connection_kind kind;
        const char *name;
        const struct id *this_id_eq; /* strict; not same_id() */
        const struct id *that_id_eq; /* strict; not same_id() */
        /* current result (can be safely deleted) */
        struct connection *c;
        /* internal: handle on next entry */
        struct list_entry *internal;
        /* internal: total matches so far */
        unsigned count;
        /* .where MUST BE LAST (See GCC bug 102288) */
        where_t where;
};

this:

+       struct connection_filter cq = {
+               .where = ({                             \
+                               static const struct where here = {      \
+                                       .func = __func__,               \
+                                       .file = __FILE__,               \
+                                       .line = __LINE__,               \
+                               };                                      \
+                               &here;                                  \
+                       }),
+       };
+       dbg("FOR_EACH_CONNECTION_... in %s %s %ld",
+           cq.where->func, cq.where->file, cq.where->line);


is mis-compiled.  It prints NULL, NULL, 0 when it should print __func__,
__FILE__, __LINE__.


Note:

- .where is last, yes that's a reall gcc bug
- only the field .where is initialized, if a second field is initialized things
seem to compile correctly
- I could include the assembler but I'm not sure of the point - the compiler
lost track of values in a static structure

-- 
You are receiving this mail because:
You are the assignee for the bug.