public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/111775] New: -Wstrict-flex-arrays missing diagnostics with unions
@ 2023-10-11 19:39 crrodriguez at opensuse dot org
  0 siblings, 0 replies; only message in thread
From: crrodriguez at opensuse dot org @ 2023-10-11 19:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111775

            Bug ID: 111775
           Summary: -Wstrict-flex-arrays missing diagnostics with unions
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crrodriguez at opensuse dot org
  Target Milestone: ---

following code is not diagnosed

#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>

struct foo {
        int dum;
union {
/* or  [1] */
        char a[0];
        wchar_t b[0];
      } fn;
};


int main(void)
{
        struct foo *f = malloc(sizeof(*f));
       /* or really any use of the union does not matter */
        printf("%p", f->fn.b);
        free(f);
        return 0;

}

compile options

-Wall -fstrict-flex-arrays -Werror=strict-flex-arrays -O2

This test is a silly mockup of real widespread code, which goes undiagnosed
until test suites run and/or is built with ubsan.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-10-11 19:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-11 19:39 [Bug middle-end/111775] New: -Wstrict-flex-arrays missing diagnostics with unions crrodriguez at opensuse dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).