-Wstrict-aliasing issue in dsymutil
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Introduced by d8e86a5cc0d5f0775faf5fc039a0c27e16dbdd61 (#182083).
When building with GCC, if using `-Werror=strict-aliasing`, one gets:
```
FAILED: [code=1] tools/dsymutil/CMakeFiles/dsymutil.dir/DebugMap.cpp.o
/usr/bin/x86_64-pc-linux-gnu-g++ -D_GLIBCXX_USE_CXX11_ABI=1 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/var/tmp/portage.notmp/portage/llvm-core/llvm-23.1.0/work/llvm_build-abi_x86_64.amd64/tools/dsymutil -I/var/tmp/portage.notmp/portage/llvm-core/llvm-23.1.0/work/llvm/tools/dsymutil -I/var/tmp/portage.notmp/portage/llvm-core/llvm-23.1.0/work/llvm_build-abi_x86_64.amd64/include -I/var/tmp/portage.notmp/portage/llvm-core/llvm-23.1.0/work/llvm/include -DNDEBUG -O3 -march=native -fno-semantic-interposition -mtls-dialect=gnu2 -fdiagnostics-color=always -Wa,-O2 -Wa,-mtune=znver4 -ggdb3 -pipe -Werror=strict-aliasing -Werror=lto-type-mismatch -Werror=odr -frecord-gcc-switches -fdiagnostics-show-context=3 -fdiagnostics-color=always -fdiagnostics-urls=never --param=ggc-min-expand=150 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-dangling-reference -Wno-redundant-move -Wno-pessimizing-move -Wno-array-bounds -Wno-stringop-overread -Wno-dangling-pointer -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -std=c++17 -fdiagnostics-color=always -MD -MT tools/dsymutil/CMakeFiles/dsymutil.dir/DebugMap.cpp.o -MF tools/dsymutil/CMakeFiles/dsymutil.dir/DebugMap.cpp.o.d -o tools/dsymutil/CMakeFiles/dsymutil.dir/DebugMap.cpp.o -c /var/tmp/portage.notmp/portage/llvm-core/llvm-23.1.0/work/llvm/tools/dsymutil/DebugMap.cpp
In file included from /var/tmp/portage.notmp/portage/llvm-core/llvm-23.1.0/work/llvm/tools/dsymutil/DebugMap.cpp:9:
/var/tmp/portage.notmp/portage/llvm-core/llvm-23.1.0/work/llvm/tools/dsymutil/DebugMap.h: In member function ‘llvm::dsymutil::DebugMap::ObjectContainer& llvm::dsymutil::DebugMap::getObjects()’:
/var/tmp/portage.notmp/portage/llvm-core/llvm-23.1.0/work/llvm/tools/dsymutil/DebugMap.h:118:48: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
118 | return reinterpret_cast(Objects);
| ^~~~~~~
/var/tmp/portage.notmp/portage/llvm-core/llvm-23.1.0/work/llvm/tools/dsymutil/DebugMap.h: In member function ‘const llvm::dsymutil::DebugMap::ObjectContainer& llvm::dsymutil::DebugMap::getObjects() const’:
/var/tmp/portage.notmp/portage/llvm-core/llvm-23.1.0/work/llvm/tools/dsymutil/DebugMap.h:121:54: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
121 | return reinterpret_cast(Objects);
| ^~~~~~~
cc1plus: some warnings being treated as errors
```
Contributor guide
Research direction
Start in tools/dsymutil/DebugMap.h at DebugMap::getObjects() and inspect the ObjectContainer and Objects declarations used by the reinterpret_cast calls. Rebuild dsymutil with GCC and -Werror=strict-aliasing, then verify that the build completes without those warnings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100