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

            Bug ID: 109953
           Summary: segmentation fault with import "functional" during
                    program execution
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: saifi.khan at nishan dot io
  Target Milestone: ---

environment GNU/Linux 6.3.3 gcc 14.0.0 glibc 2.37-3

command 'g++ -std=c++23 -v -g3 -Wall -fmodules-ts'

Here is the program

import "iostream";
import "functional";
import "string_view";

auto test (std::string_view sv) -> void {

      std::cout << sv.substr (std::size_t {0}, std::size_t {8})
                << '\n';
}

auto main () -> int {

     test ("Free Software Community");

return 0;
}

When the program is executed, it encounters a segmentation fault.

The stack trace is as follows

Program received signal SIGSEGV, Segmentation fault.
0x0000555555555344 in std::min<unsigned long> (__a=@0x7fffffffe0d8: 8,
__b=@0x7fffffffe0f8: 23) at /opt/gcc/include/c++/14.0.0/bits/stl_algobase.h:238
238           if (__b < __a)
(gdb) bt
#0  0x0000555555555344 in std::min<unsigned long> (__a=@0x7fffffffe0d8: 8,
__b=@0x7fffffffe0f8: 23) at /opt/gcc/include/c++/14.0.0/bits/stl_algobase.h:238
#1  0x00005555555553bf in std::basic_string_view<char, std::char_traits<char>
>::substr (this=0x7fffffffe130, __pos=0, __n=8)
    at /opt/gcc/include/c++/14.0.0/string_view:336
#2  0x00005555555551c4 in test (sv="Free Software Community") at
str_view_01.cc:10
#3  0x0000555555555230 in main () at str_view_01.cc:16
(gdb) 


NOTE
when the line 'import "functional";' is commented out and the program is
re-compiled. It executes and prints the expected result "Free Sof".

Reply via email to