gcc-14 bugs, pile 4
In a few weeks gcc-14
branch should see a 14.1.0
release.
Since November 2023 I encountered only 8 more bugs. That makes it 2 bugs per month. 4 time lower rate than I had last time.
summary
Bugs I saw (in discovery order):
- tree-optimization/112711: wrong code
on
llvm-16
,bswap
andassume(aligned)
. - c++/112869:
ICE
onlibmpt-0.7.3
when built with-std=c++20
. - tree-optimization/112991:
ICE
onp7zip
due to value numbering bugs. - bootstrap/113132: bootstrap build
failure due to
-Werror
. - bootstrap/113445: bootstrap comparison failure due to instruction scheduler changes.
- tree-optimization/114249:
ICE
onlvm2
(wrong type transform inSLP
). - c++/114439:
icu4c
build failure due to the initialization changes inc++
. - lto/114574:
unbound
ICE in-flto
mode.
fun bug
Only one of 8 bug was a runtime failure on llvm-16
in
__builtin_assume_aligned()
handling code. It’s extracted from
EndiaTest.cpp
:
// $ cat EndianTest.cpp
typedef int i32;
typedef unsigned int u32;
static inline void write_i32(void *memory, i32 value) {
// swap i32 bytes as if it was u32:
= value;
u32 u_value = __builtin_bswap32(u_value);
value
// llvm infers '1' alignment from destination type
(__builtin_assume_aligned(memory, 1), &value, sizeof(value));
__builtin_memcpy}
((noipa))
__attribute__static void bug (void) {
#define assert_eq(lhs, rhs) if (lhs != rhs) __builtin_trap()
unsigned char data[5];
(data, -1362446643);
write_i32(data[0], 0xAE);
assert_eq(data[1], 0xCA);
assert_eq(data + 1, -1362446643);
write_i32(data[1], 0xAE);
assert_eq}
int main() {
();
bug}
The optimization breaks simple store-32
/ load-8
/ compare
sequence:
$ gcc/xg++ -Bgcc EndianTest.cpp -o bug -O0 && ./bug
$ gcc/xg++ -Bgcc EndianTest.cpp -o bug -O2 && ./bug
Illegal instruction (core dumped)
There gcc
was too optimistic in assuming that
__builtin_assume_aligned()
returns address not aliased to input
argument. As a result gcc
erroneously removed dead-looking stores.
The fix drops overly optimistic assumption.
histograms
tree-optimization
: 3c++
: 2bootstrap
: 2lto
: 1
We are back to the usual tree-optimization
at the top of subsystems
where bugs lurked.
parting words
This cycle felt easier than the previous three. It feels like gcc-14
is ready for release.
Since the time gcc-13
was released about a year ago I found 53 bugs
(past piles
1,
2,
3).
This is about one bug a week.
I think the most impactful gcc-14
change will probably be
-Werror=implicit-int
, -Werror=implicit-function-declaration
and
friends (see https://gcc.gnu.org/gcc-14/porting_to.html for more
details). This will break quite a few old unmaintained but used
everywhere C projects like zip
, opensp
, jam
, directfb
.
Have fun!