Regression (segfault) with std::print and __int128 using libstdc++6 17.0.0+20260802-0.1

martin_n_fuller martin_n_fuller@btinternet.com
Sun Aug 23 01:51:18 GMT 2026


The following test program compiles and runs successfully with clang 
20.1.8-2 and libstdc++6 16.1.1+20260801-0.1.
The same program compiled and run with libstdc++6 17.0.0+20260802-0.1 
exits with a segmentation fault.

#include <print>
int main(int argc, char *argv[]) {
   std::println("{}", static_cast<__int128>(argc) << 100);
}

$ clang++ -std=c++23 -g test.cpp -o test
$ ./test
1267650600228229401496703205376 (with 16.1.1)
Segmentation fault (with 17.0.0)

Martin

PS The same program fails to compile with gcc (16.1.1 or 17.0.0).
$ g++ -std=c++23 -g test.cpp -o test
In file included from 
/usr/lib/gcc/x86_64-pc-cygwin/17/include/c++/print:53,
                  from test.cpp:1:
/usr/lib/gcc/x86_64-pc-cygwin/17/include/c++/bits/print.h: In 
constructor ‘std::__format::_File_sink::_File::_File(FILE*)’:
/usr/lib/gcc/x86_64-pc-cygwin/17/include/c++/bits/print.h:198:52: error: 
‘::flockfile’ has not been declared; did you mean ‘_flockfile’?
   198 |       explicit _File(FILE* __f) : _M_file(__f) { 
::flockfile(_M_file); }
       |                                                    ^~~~~~~~~
       |                                                    _flockfile
/usr/lib/gcc/x86_64-pc-cygwin/17/include/c++/bits/print.h: In destructor 
‘std::__format::_File_sink::_File::~_File()’:
/usr/lib/gcc/x86_64-pc-cygwin/17/include/c++/bits/print.h:199:20: error: 
‘::funlockfile’ has not been declared; did you mean ‘_funlockfile’?
   199 |       ~_File() { ::funlockfile(_M_file); }
       |                    ^~~~~~~~~~~
       |                    _funlockfile
/usr/lib/gcc/x86_64-pc-cygwin/17/include/c++/bits/print.h: In member 
function ‘virtual void std::__format::_File_sink::_M_overflow()’:
/usr/lib/gcc/x86_64-pc-cygwin/17/include/c++/bits/print.h:211:20: error: 
‘::fwrite_unlocked’ has not been declared; did you mean 
‘_fwrite_unlocked_r’?
   211 |       auto __n = ::fwrite_unlocked(__s.data(), 1, __s.size(), 
_M_file._M_file);
       |                    ^~~~~~~~~~~~~~~
       |                    _fwrite_unlocked_r
/usr/lib/gcc/x86_64-pc-cygwin/17/include/c++/bits/print.h: In destructor 
‘std::__format::_File_sink::~_File_sink()’:
/usr/lib/gcc/x86_64-pc-cygwin/17/include/c++/bits/print.h:232:11: error: 
‘::putc_unlocked’ has not been declared; did you mean 
‘_putc_unlocked_r’?
   232 |         ::putc_unlocked('\n', _M_file._M_file);
       |           ^~~~~~~~~~~~~
       |           _putc_unlocked_r


More information about the Cygwin mailing list