[Bug c++/95422] New: Possible false positive for -Waddress-of-packed-member.

ldalessandro at gmail dot com gcc-bugzilla@gcc.gnu.org
Fri May 29 18:15:26 GMT 2020


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

            Bug ID: 95422
           Summary: Possible false positive for
                    -Waddress-of-packed-member.
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ldalessandro at gmail dot com
  Target Milestone: ---

I get some confusing results from the following code.

https://godbolt.org/z/p5uZgH

>  struct [[ gnu::packed ]] Foo { 
>      Foo() : x{} {} // <-- #1, x{}
>      void* x[1];
>  } foo;
>  
>  struct [[ gnu::packed ]] Bar { 
>      Bar() : x() {} // <-- #2, x() !!!-Waddress-of-packed-member!!!
>      void* x[1];
>  } bar;
>  
>  struct FooBar { 
>      FooBar() : x() {} // <-- #3, x(), no packed attr
>      void* x[1];
>  } foobar;
I'm seeing the -Waddress-of-packed-member trigger for #2 with g++ (clang++
never produces it), and I can't figure out why this particular use is special.


More information about the Gcc-bugs mailing list