https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118981

--- Comment #49 from Erich Löw <Erich.Loew at outlook dot com> ---
Yep, understood: using priorities below 101 in user code is forbidden.

I was just eager to see if using reserved priority 99 in user code together
with production compiler would trigger the duplicating of symbol entry ...99
and what would happen if using priority 98.

I added a short reproduction
- Main.cc: attachment in comment 45
- Makefile: attachment in comment 46
- Main.s: attachment in comment 47

Compiling Main.cc delivers

root:/home/SETUP/Examples/GNU-118981> make
g++ -I./ -pipe -march=native -O2 -fPIC -fomit-frame-pointer -S -L -fverbose-asm
-ffunction-sections -fdata-sections -Wl,-z,relro -rdynamic -fvtable-verify=std 
-c Main.cc -o Main.s
Main.cc:40:12: warning: requested ‘init_priority’ 99 is reserved for internal
use [-Wprio-ctor-dtor]
   40 | Coord A::c0(4u, 5u);
      |            ^
as  -I./   -c Main.s  -o Main.o
Main.s: Assembler messages:
Main.s:808: Error: symbol `_GLOBAL__sub_I.00099_Main.cc' is already defined

grep Main.s shows duplicated _GLOBAL__sub_I.00099

root:/home/SETUP/Examples/GNU-118981> grep _GLOBAL__sub_I.00099 Main.s
        .section       
.text.startup._GLOBAL__sub_I.00099_Main.cc,"ax",@progbits
        .type   _GLOBAL__sub_I.00099_Main.cc, @function
_GLOBAL__sub_I.00099_Main.cc:
        .size   _GLOBAL__sub_I.00099_Main.cc, .-_GLOBAL__sub_I.00099_Main.cc
        .quad   _GLOBAL__sub_I.00099_Main.cc
        .section        .text.startup._GLOBAL__sub_I.00099_Main.cc
        .type   _GLOBAL__sub_I.00099_Main.cc, @function
_GLOBAL__sub_I.00099_Main.cc:
        .size   _GLOBAL__sub_I.00099_Main.cc, .-_GLOBAL__sub_I.00099_Main.cc
        .quad   _GLOBAL__sub_I.00099_Main.cc

I reproducd with LATEST GCC (production)

root:/home/SETUP/Examples/GNU-118981> gcc --version
gcc (GCC) 15.0.1 20250222 (experimental)
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.

The duplicate pops up if using "[[gnu::init_priority(99)]]"
Other priorities (like 98) compile.

Reply via email to