gcc-14 bugs, pile 1
Around beginning of the May gcc-14
development got opened for major
changes to be merged into master
branch. 2 months have passed since
and I collected a “round” number of bugs: 16. Today is also a day when I
managed to build my whole system by gcc-master
without encountering
any obvious bugs.
Summary
Here is the full list of bugs I encountered in chronological order:
ipa/109643
:ICE
onpkg-config
ipa/109652
:ICE
onvalgrind
tree-optimization/109732
: wrong code onjson
test suite.c++/109755
: imprecise warning location.tree-optimization/110067
: wrong code onpixman
test suite.middle-end/110228
: wrong code onllvm
JIT test suite.tree-optimization/110271
:ICE
onpycryptodome
target/110274
: wrong code onhighway
test suite.debug/110308
:ICE
onaudiofile
.tree-optimization/110332
:ICE
onllvm
.middle-end/110443
:ICE
ona52dec
.middle-end/110515
: wrong code onllvm
DWARF
test suite.c++/110523
:ICE
onjson
.c++/110580
: rejects valid onnix
code.c++/110598
: wrong code forllvm
AMDGCN
test suite.tree-optimization/110601
:ICE
onsystemd
.
Let’s look at a few histograms. Looking at the manifestation of the bug:
ICE
: 8wrong-code
: 6other
: 2
Wrong code is almost as much as compiler crashes. Some of wrong codes took me a while to extract from the real project. Once again robust test suites make it so much easier to extract an example for upstream reporting.
Looking at the subsystems:
tree-optimization
: 5c++
: 4middle-end
: 3ipa
: 2debug
: 1target
: 1
Half the bugs happened in generic optimization phase (tree-optimization
and middle-end
). A few bugs in c++
frontend (mainly in tempalte
instantiation code). And only one failure was target-specific. It should
be obvious by now that I did no test gcc
on anything besides x86_64
:).
Tip of the day
When chasing wrong code generation down to a particular source file I
found the #pragma GCC optimize(1)
injection hack to be useful:
# flip first halg to -O1
$ git grep -LF 'pragma GCC optimize' -- '**.cpp' | head -n $NUMBER |
xargs sed '1i #pragma GCC optimize(1)' -i
# flip second half to -O1
$ git grep -LF 'pragma GCC optimize' -- '**.cpp' | tail -n +$(($NUMBER+1)) |
xargs sed '1i #pragma GCC optimize(1)' -i
That way I flip $NUMBER
files down to -O1
optimization level
(assuming it is enough to inhibit the bug from happening) and bisect it
down to a single file without -O1
injected.
ccache
makes pragma addition and removal very cheap. You effectively
need to compile project only twice: with default options and with -O1
pragma override. The rest is a bit of linking.
Parting words
Running gcc-master
is still a lot of fun. I keep finding ~2 new bugs
per week on a regular basis. I did not get to fix any of them: in almost
all cases maintainers figured out the fix way before I got closer to the
culprit code in gcc
. Maybe one day I’ll get there first :)
llvm
and json
remain to be the hardest stress tests for gcc
.
Have fun!