[Bug c++/68901] UBSan triggers false -Wpadded warning

vanyacpp at gmail dot com gcc-bugzilla@gcc.gnu.org
Fri Jul 29 23:47:00 GMT 2016


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

Ivan Sorokin <vanyacpp at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vanyacpp at gmail dot com

--- Comment #1 from Ivan Sorokin <vanyacpp at gmail dot com> ---
I experienced the same issue on GCC 5.3.0. I made a minimal reprocase for the
issue.

struct mytype
{
    void f()
    {
        value = 42;
    }

    unsigned value;
};

void foo()
{
    mytype().f();
}

$ g++ -Wpadded -fsanitize=undefined 2.cpp
2.cpp: In member function ‘void mytype::f()’:
2.cpp:3:10: warning: padding struct size to alignment boundary [-Wpadded]
     void f()
          ^
2.cpp: In function ‘void foo()’:
2.cpp:11:6: warning: padding struct size to alignment boundary [-Wpadded]
 void foo()
      ^


More information about the Gcc-bugs mailing list