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

            Bug ID: 120315
           Summary: std::format gcc 14 / 15 interop issue
           Product: gcc
           Version: 15.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nilsgladitz at gmail dot com
  Target Milestone: ---

Created attachment 61443
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61443&action=edit
Testcase

I got undefined behavior (segfault, missing output or exceptions) when using a
gcc 14 compiled library with a gcc 15 compiled executable.

The issue does not seem to be reproducible when the same compiler is used for
both the library and the compiler.

Attached is a reduced test case that I compile on x86_64 GNU Linux thusly:

/opt/gcc-14.2.0/bin/g++ -fvisibility=hidden -fvisibility-inlines-hidden -shared
-fPIC -std=c++23 library.cpp -o liblibrary14.so -Wl,-soname,liblibrary14.so
/opt/gcc-15.1.0/bin/g++ -fvisibility=hidden -fvisibility-inlines-hidden -shared
-fPIC -std=c++23 library.cpp -o liblibrary15.so -Wl,-soname,liblibrary15.so

/opt/gcc-15.1.0/bin/g++ -std=c++23 executable.cpp -o executable14
liblibrary14.so '-Wl,-rpath,$ORIGIN' 
/opt/gcc-15.1.0/bin/g++ -std=c++23 executable.cpp -o executable15
liblibrary15.so '-Wl,-rpath,$ORIGIN'

Running executable15 I get the expected output:
Hello World

Running executable14 I get e.g.:
terminate called after throwing an instance of 'std::format_error'
  what():  format error: invalid arg-id in format string
Aborted (core dumped)

I am unsure if maybe std::format isn't supposed to be ABI stable yet or if
there is something else not being done properly / well defined in the test
case.

Reply via email to