public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "adamstepniak41 at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/111447] New: Program crashes when an include is present in global module fragment
Date: Sun, 17 Sep 2023 19:20:22 +0000	[thread overview]
Message-ID: <bug-111447-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 111447
           Summary: Program crashes when an include is present in global
                    module fragment
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: adamstepniak41 at gmail dot com
  Target Milestone: ---

animal.cpp
-----------
module;
#include <string>
export module animal;
export import :sound;
----------

animal_sound.cpp
----------
module;
#include <string> // Comment this to get rid of crash
export module animal:sound;

export std::string makeSound() {
 return "Wroooarrh";
}
----------

main.cpp
----------
#include <cstdio>

import animal;

int main() {
 auto s = makeSound();
 printf("%s", s.c_str());
 return 0;
}
----------

Program crashes when compiled with:
----------
g++ -fmodules-ts -g -std=c++20 -Wall -Wextra -fno-strict-aliasing -fwrapv
animal_sound.cpp -c -o animal_sound.o
g++ -fmodules-ts -g -std=c++20 -Wall -Wextra -fno-strict-aliasing -fwrapv
animal.cpp -c -o animal.o
g++ -fmodules-ts -g -std=c++20 -Wall -Wextra -fno-strict-aliasing -fwrapv
animal.o animal_sound.o main.cpp -o main.exe
----------

Call stack:
Program received signal SIGSEGV, Segmentation fault.
0x000055555555667c in std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >::_M_data (this=0x8fa71c45df267600) at
/usr/include/c++/13/bits/basic_string.h:223
223           { return _M_dataplus._M_p; }
(gdb) bt
#0  0x000055555555667c in std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> >::_M_data (this=0x0) at
/usr/include/c++/13/bits/basic_string.h:223
#1  0x0000555555556ef4 in std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> >::c_str (this=0x7fffffffda60) at
/usr/include/c++/13/bits/basic_string.h:2584
#2  0x0000555555556e60 in main () at main.cpp:7

Compiler version:
g++ --version
g++ (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0

             reply	other threads:[~2023-09-17 19:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-17 19:20 adamstepniak41 at gmail dot com [this message]
2023-09-17 19:24 ` [Bug c++/111447] " pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-111447-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).