public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "headch at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/110861] New: Bad codegen leading to runtime segfault when mixing import and #include Date: Mon, 31 Jul 2023 15:02:24 +0000 [thread overview] Message-ID: <bug-110861-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110861 Bug ID: 110861 Summary: Bad codegen leading to runtime segfault when mixing import and #include Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: headch at gmail dot com Target Milestone: --- $ g++-13 --version g++-13 (Gentoo 13.2.0 p3) 13.2.0 Copyright (C) 2023 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. $ cat hello.cpp #include <string_view> import <iostream>; void f(std::string_view sv) { std::cout << sv; } int main() { f("hello\n"); } $ g++-13 -O1 -Wall -Wextra -c -std=c++20 -x c++-system-header -fmodules-ts -fmodule-header=system iostream $ g++-13 -std=c++20 -O1 -Wall -Wextra -fmodules-ts -ohello hello.cpp In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13/bits/basic_string.h:47, from /usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13/string:54, from /usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13/bits/locale_classes.h:40, from /usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13/bits/ios_base.h:41, from /usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13/ios:44, from /usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13/ostream:40, from /usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13/iostream:41, of module /usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13/iostream, imported at hello.cpp:2: In member function ‘constexpr const std::basic_string_view<_CharT, _Traits>::value_type* std::basic_string_view<_CharT, _Traits>::data() const [with _CharT = char; _Traits = std::char_traits<char>]’, inlined from ‘std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, basic_string_view<_CharT, _Traits>) [with _CharT = char; _Traits = char_traits<char>]’ at /usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13/string_view:762:30, inlined from ‘void f(std::string_view)’ at hello.cpp:5:15: /usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13/string_view:292:22: warning: ‘this’ is used uninitialized [-Wuninitialized] 292 | { return this->_M_str; } | ^~~~~~ In file included from hello.cpp:1: /usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13/string_view: In function ‘void f(std::string_view)’: /usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13/string_view:760:5: note: ‘this’ was declared here 760 | operator<<(basic_ostream<_CharT, _Traits>& __os, | ^~~~~~~~ $ ./hello Segmentation fault (core dumped) If I use optimization level zero, the problem goes away (both the segfault and the “uninitialized” warning). Likewise if I import both headers rather than including one of them. But as far as I’m aware, I haven’t found any indication that the stdlib is required to be either all-included or all-imported and not a mix.
next reply other threads:[~2023-07-31 15:02 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-07-31 15:02 headch at gmail dot com [this message] 2023-07-31 15:05 ` [Bug c++/110861] " headch at gmail dot com 2024-03-06 16:47 ` ppalka at gcc dot gnu.org 2024-03-06 18:01 ` ppalka 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-110861-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: linkBe 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).