https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93630
--- Comment #3 from Rodrigo Rivas <rodrigorivascosta at gmail dot com> ---
(In reply to Jakub Jelinek from comment #1)
> Can't reproduce, neither with 9.x, nor trunk, nor various revisions in
> between, different optimization levels etc. I get '' in all places where it
> should be.
> What exact g++ version are you using, what exact target, what exact g++
> options?
I'm using an up-to-date x64 ArchLinux:
* `g++ --version` reports 9.2.0 (packaged as gcc-9.2.0-4) [1]
* `ld --version` reports 2.33.1 (packaged as binutils-2.33.1-2)
I'm using just `g++ test.cpp`, that will be the x86_64-unknown-linux-gnu
target. I tried also with different optimizations: -O0 -O1, -O2, -O3, -Os,
-Ofast... all the same results.
I've also tried with `-m32`, no changes. I happen to have installed
mingw-w64-gcc version 9.1.0, and running the EXE with Wine, and it also
reproduces the issue.
Doing what Andrew Pinski suggests, adding `-no-pie` changes nothing either.
To discard a weird binutils, I've run the compiler with `g++ -O0 --no-pie
test.cpp -S` and it gives:
.file "test.cpp"
.text
.section .rodata
.LC0:
.string "AA"
.LC1:
.string "AB"
.LC2:
.string "BA"
.LC3:
.string ""
.LC4:
.string "XX"
.align 32
.type _ZL5group, @object
.size _ZL5group, 72
_ZL5group:
.quad .LC0
.quad .LC1
.zero 8
.quad .LC2
.zero 16
.quad .LC3
.quad .LC3
.quad .LC4
...
Even in the assembly, you can see how the NULL pointers creep into the array.
Adding the option `-x c` to the above command to force C produces instead:
.file "test.cpp"
.text
.globl group
.section .rodata
.LC0:
.string "AA"
.LC1:
.string "AB"
.LC2:
.string ""
.LC3:
.string "BA"
.LC4:
.string "XX"
.align 32
.type group, @object
.size group, 72
group:
.quad .LC0
.quad .LC1
.quad .LC2
.quad .LC3
.quad .LC2
.quad .LC2
.quad .LC2
.quad .LC2
.quad .LC4
...
1: Details at:
https://git.archlinux.org/svntogit/packages.git/tree/trunk?h=packages/gcc
It looks like there are no distro-specific C++ patches, only a few for D.