[Bug c++/81668] New: LTO ODR warnings are not helpful
sgunderson at bigfoot dot com
gcc-bugzilla@gcc.gnu.org
Wed Aug 2 11:54:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81668
Bug ID: 81668
Summary: LTO ODR warnings are not helpful
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: sgunderson at bigfoot dot com
Target Milestone: ---
Hi,
I'm trying to make MySQL compile with LTO. There are a lot of ODR violations
(which I'm trying to fix), but sometimes, the warnings are too vague to give
any real information. An example:
[797/1336] Building CXX object
unittest/gunit/CMakeFiles/merge_large_tests-t.dir/opt_ref-t.cc.o
In file included from ../include/my_byteorder.h:53:0,
from ../include/m_ctype.h:29,
from ../include/my_compare.h:25,
from ../sql/field.h:22,
from ../unittest/gunit/fake_table.h:27,
from ../unittest/gunit/opt_ref-t.cc:23:
../include/template_utils.h: In instantiation of 'T pointer_cast(void*) [with T
= unsigned char* const]':
../sql/sql_optimizer.cc:9901:60: required from here
../include/template_utils.h:70:10: warning: type qualifiers ignored on cast
result type [-Wignored-qualifiers]
return static_cast<T>(p);
^~~~~~~~~~~~~~~~~
[852/1336] Linking CXX executable runtime_output_directory/pfs-t
../storage/perfschema/pfs.h:72:40: warning: type of 'THR_PFS_contexts' does not
match original declaration [-Wlto-type-mismatch]
extern thread_local PFS_table_context *THR_PFS_contexts[THR_PFS_NUM_KEYS];
^
../storage/perfschema/pfs.cc:2072:33: note: 'THR_PFS_contexts' was previously
declared here
thread_local PFS_table_context *THR_PFS_contexts[THR_PFS_NUM_KEYS];
^
../storage/perfschema/pfs.cc:2072:33: note: code may be misoptimized unless
-fno-strict-aliasing is used
[854/1336] Linking CXX executable runtime_output_directory/pfs_instr-t
../storage/perfschema/pfs.h:72:40: warning: type of 'THR_PFS_contexts' does not
match original declaration [-Wlto-type-mismatch]
extern thread_local PFS_table_context *THR_PFS_contexts[THR_PFS_NUM_KEYS];
^
../storage/perfschema/pfs.cc:2072:33: note: 'THR_PFS_contexts' was previously
declared here
thread_local PFS_table_context *THR_PFS_contexts[THR_PFS_NUM_KEYS];
^
../storage/perfschema/pfs.cc:2072:33: note: code may be misoptimized unless
-fno-strict-aliasing is used
[855/1336] Linking CXX executable runtime_output_directory/pfs_instr_class-t
../storage/perfschema/pfs.h:72:40: warning: type of 'THR_PFS_contexts' does not
match original declaration [-Wlto-type-mismatch]
extern thread_local PFS_table_context *THR_PFS_contexts[THR_PFS_NUM_KEYS];
^
../storage/perfschema/pfs.cc:2072:33: note: 'THR_PFS_contexts' was previously
declared here
thread_local PFS_table_context *THR_PFS_contexts[THR_PFS_NUM_KEYS];
^
../storage/perfschema/pfs.cc:2072:33: note: code may be misoptimized unless
-fno-strict-aliasing is used
[856/1336] Linking CXX executable runtime_output_directory/pfs_account-oom-t
../storage/perfschema/pfs.h:72:40: warning: type of 'THR_PFS_contexts' does not
match original declaration [-Wlto-type-mismatch]
extern thread_local PFS_table_context *THR_PFS_contexts[THR_PFS_NUM_KEYS];
^
../storage/perfschema/pfs.cc:2072:33: note: 'THR_PFS_contexts' was previously
declared here
thread_local PFS_table_context *THR_PFS_contexts[THR_PFS_NUM_KEYS];
^
../storage/perfschema/pfs.cc:2072:33: note: code may be misoptimized unless
-fno-strict-aliasing is used
[857/1336] Linking CXX executable runtime_output_directory/pfs_host-oom-t
../storage/perfschema/pfs.h:72:40: warning: type of 'THR_PFS_contexts' does not
match original declaration [-Wlto-type-mismatch]
extern thread_local PFS_table_context *THR_PFS_contexts[THR_PFS_NUM_KEYS];
^
../storage/perfschema/pfs.cc:2072:33: note: 'THR_PFS_contexts' was previously
declared here
thread_local PFS_table_context *THR_PFS_contexts[THR_PFS_NUM_KEYS];
^
../storage/perfschema/pfs.cc:2072:33: note: code may be misoptimized unless
-fno-strict-aliasing is used
[858/1336] Linking CXX executable runtime_output_directory/pfs_user-oom-t
../storage/perfschema/pfs.h:72:40: warning: type of 'THR_PFS_contexts' does not
match original declaration [-Wlto-type-mismatch]
extern thread_local PFS_table_context *THR_PFS_contexts[THR_PFS_NUM_KEYS];
^
../storage/perfschema/pfs.cc:2072:33: note: 'THR_PFS_contexts' was previously
declared here
thread_local PFS_table_context *THR_PFS_contexts[THR_PFS_NUM_KEYS];
^
../storage/perfschema/pfs.cc:2072:33: note: code may be misoptimized unless
-fno-strict-aliasing is used
[859/1336] Linking CXX executable
runtime_output_directory/pfs_instr_class-oom-t
../storage/perfschema/pfs.h:72:40: warning: type of 'THR_PFS_contexts' does not
match original declaration [-Wlto-type-mismatch]
extern thread_local PFS_table_context *THR_PFS_contexts[THR_PFS_NUM_KEYS];
^
../storage/perfschema/pfs.cc:2072:33: note: 'THR_PFS_contexts' was previously
declared here
thread_local PFS_table_context *THR_PFS_contexts[THR_PFS_NUM_KEYS];
^
../storage/perfschema/pfs.cc:2072:33: note: code may be misoptimized unless
-fno-strict-aliasing is used
[860/1336] Linking CXX executable runtime_output_directory/pfs_instr-oom-t
../storage/perfschema/pfs.h:72:40: warning: type of 'THR_PFS_contexts' does not
match original declaration [-Wlto-type-mismatch]
extern thread_local PFS_table_context *THR_PFS_contexts[THR_PFS_NUM_KEYS];
^
../storage/perfschema/pfs.cc:2072:33: note: 'THR_PFS_contexts' was previously
declared here
thread_local PFS_table_context *THR_PFS_contexts[THR_PFS_NUM_KEYS];
^
../storage/perfschema/pfs.cc:2072:33: note: code may be misoptimized unless
-fno-strict-aliasing is used
>From what I can see, class PFS_table_context and THR_PFS_NUM_KEYS all have the
same definition in all translation units, so it's not clear to me at all what
it's complaining about. I'd try to make a minimal example, but I can't even
figure out which .o files are involved (it would certainly help to know; there
are hundreds or thousands of them being linked together).
Similarly, I get these warnings:
fts0pars.y:62:0: note: a field with different name is defined in another
translation unit
../include/violite.h:288:8: warning: type ‘struct st_vio’ violates the C++ One
Definition Rule [-Wodr]
struct st_vio
^
../include/violite.h:288:0: note: a different type is defined in another
translation unit
struct st_vio
../include/violite.h:339:46: note: the first difference of corresponding
definitions is field ‘viodelete’
void (*viodelete)(MYSQL_VIO)= { nullptr };
^
../include/violite.h:339:0: note: a field of same name but different type is
defined in another translation unit
void (*viodelete)(MYSQL_VIO)= { nullptr };
Near as I can see, there's no difference here. MYSQL_VIO is a macro to Vio* in
all translation units as far as I can see. But it's impossible for me to say if
the warning is wrong or if the code is wrong.
This is both with GCC 7.1.0 and a recent snapshot:
Using built-in specs.
COLLECT_GCC=/usr/lib/gcc-snapshot/bin/g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc-snapshot/libexec/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 20170618-1'
--with-bugurl=file:///usr/share/doc/gcc-snapshot/README.Bugs
--enable-languages=c,ada,c++,go,brig,fortran,objc,obj-c++
--prefix=/usr/lib/gcc-snapshot --with-gcc-major-version-only --program-prefix=
--enable-shared --enable-linker-build-id --disable-nls --with-sysroot=/
--enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib
--enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib
--with-tune=generic --enable-offload-targets=nvptx-none --enable-checking=yes
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170618 (experimental) [trunk revision 249349] (Debian
20170618-1)
More information about the Gcc-bugs
mailing list