https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120955
--- Comment #18 from fiesh at zefix dot tv ---
Ok, finally here's a reduced testcase:
-----8<-----
typedef int c __attribute__((__mode__(__SI__)));
typedef int d __attribute__((__mode__(__SI__)));
template < typename f, int g > struct h {
typedef f i[g];
};
template < typename f, int g > struct ab {
h< f, g >::i j;
};
template < typename k > struct ad {
k ae;
ad(k l) : ae(l) {}
};
struct af {
ab< char, 6 > m;
};
enum n { y = 6 };
struct o {
ab< char, 4 > m;
};
struct ar {
ad< d > as{600};
n at{y};
};
struct au {
af av;
o aw;
o ax;
o ay;
o az;
o a{2, 8, 2, 1};
o b{2, 8, 2, 1};
};
struct bc {
c d;
c e;
c f;
int bg;
int bh;
int bi;
int bj;
char bk;
char bl;
int bm;
int bn;
int bo;
bool p;
int bp;
int bq;
c br;
int bs;
int bt{60};
c b;
int bv{60};
c bw{10000};
int bx{60};
int by{60};
c bz;
ad< int > a{50};
};
struct cb {
au cc;
ar cd;
bc ce;
};
void f(cb &ch) {
ch = {};
ch.cd = {};
ch.cc.ay = au{}.ay;
ch.ce = {};
}
-----8<-----
For the records, the interestingness test to produce it was
TMPFILE=`mktemp /tmp/tmp.XXXXX.ii`
cat a.ii > $TMPFILE
podman exec 86af579e3591 sh -c "avr-g++ -fno-exceptions -std=c++20 -Os -g0
-ffunction-sections -fdata-sections -fmerge-all-constants -fstrict-enums
-ffast-math -fassociative-math -freciprocal-math -fno-signed-zeros
-fno-exceptions -fno-threadsafe-statics -fimplicit-constexpr -mmcu=atmega2560
-fvisibility=hidden -o $TMPFILE.o -c $TMPFILE && avr-size -G $TMPFILE.o | grep
-v text | awk '{ print \$2; }' > $TMPFILE.size && test \`cat $TMPFILE.size\`
-ge 194" &&
podman exec 267b0fab5455 sh -c "avr-g++ -fno-exceptions -std=c++20 -Os -g0
-ffunction-sections -fdata-sections -fmerge-all-constants -fstrict-enums
-ffast-math -fassociative-math -freciprocal-math -fno-signed-zeros
-fno-exceptions -fno-threadsafe-statics -fimplicit-constexpr -mmcu=atmega2560
-fvisibility=hidden -o $TMPFILE.o -c $TMPFILE && avr-size -G $TMPFILE.o | grep
-v text | awk '{ print \$2; }' > $TMPFILE.size && test \`cat $TMPFILE.size\`
-le 31" &&
rm -f $TMPFILE $TMPFILE.o $TMPFILE.size
with 86a being an alpine 3.22 and 267 being an alpine 3.21 container.
It reproduces the aforementioned data sizes:
~ % podman run -it -v /tmp:/tmp alpine:3.21 sh -c 'sed -i -e s/https/http/
/etc/apk/repositories && apk -q add gcc-avr && avr-g++ --version && avr-g++
-fno-exceptions -std=c++20 -Os -g0 -ffunction-sections -fdata-sections
-fmerge-all-constants -fstrict-enums -ffast-math -fassociative-math
-freciprocal-math -fno-signed-zeros -fno-exceptions -fno-threadsafe-statics
-fimplicit-constexpr -mmcu=atmega2560 -fvisibility=hidden -o /a.o -c /tmp/a.ii
&& avr-size -G /a.o'
avr-g++ (Alpine Linux) 14.2.0
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
text data bss total filename
302 30 0 332 /a.o
~ % podman run -it -v /tmp:/tmp alpine:3.22 sh -c 'sed -i -e s/https/http/
/etc/apk/repositories && apk -q add gcc-avr && avr-g++ --version && avr-g++
-fno-exceptions -std=c++20 -Os -g0 -ffunction-sections -fdata-sections
-fmerge-all-constants -fstrict-enums -ffast-math -fassociative-math
-freciprocal-math -fno-signed-zeros -fno-exceptions -fno-threadsafe-statics
-fimplicit-constexpr -mmcu=atmega2560 -fvisibility=hidden -o /a.o -c /tmp/a.ii
&& avr-size -G /a.o'
avr-g++ (Alpine Linux) 15.1.0
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
text data bss total filename
126 194 0 320 /a.o