public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/112624] New: Internal compiler error when compiling a module
@ 2023-11-19 16:44 amaikinono at gmail dot com
  2024-03-26 13:39 ` [Bug c++/112624] " nshead at gcc dot gnu.org
  2024-03-26 14:52 ` ppalka at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: amaikinono at gmail dot com @ 2023-11-19 16:44 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112624
           Summary: Internal compiler error when compiling a module
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: amaikinono at gmail dot com
  Target Milestone: ---

Created attachment 56644
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56644&action=edit
Preprocessed file.

Sorry for the vague title as I am still new to C++ and don't have better
understanding of the bug.

Here are the source files:

```
// mod.cxx
module;
#include <string>
export module mod;

export class Example
{
public:
  const std::string& display() const;
};
```

```
// mod_impl.cpp
#include <format>
#include <string>

const std::string& display()
{
  return std::format("hi {}", 1);
}
```

Compile it:

```
$ g++ -std=c++20 -fmodules-ts -c mod.cxx
[kino@kino-pc /yard/new-box/works/code-snippets/2023-professional-cpp/gcc-bug]
$ g++ -std=c++20 -fmodules-ts -c mod.o mod_impl.cpp
mod_impl.cpp: In function ‘const std::string& display()’:
mod_impl.cpp:6:21: warning: returning reference to temporary
[]8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wreturn-local-addr-Wreturn-local-addr]8;;]
    6 |   return std::format("hi {}", 1);
      |          ~~~~~~~~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/13.2.1/bits/locale_classes.h:869,
                 from /usr/include/c++/13.2.1/locale:41,
                 from /usr/include/c++/13.2.1/format:42,
of module /usr/include/c++/13.2.1/format, imported at mod_impl.cpp:1:
/usr/include/c++/13.2.1/bits/locale_classes.tcc: In instantiation of ‘const
_Facet& std::use_face
(const locale&) [with _Facet = ctype<wchar_t>]’:
/usr/include/c++/13.2.1/format:2135:45:   required from ‘typename
std::basic_format_context<_Out, _CharT>::iterator std::formatter<const void*,
_CharT>::format(const void*, std::basic_format_context<_Out, _CharT>&) const
[with _Out = std::__format::_Sink_iter<wchar_t>; _CharT = wchar_t; typename
std::basic_format_context<_Out, _CharT>::iterator =
std::basic_format_context<std::__format::_Sink_iter<wchar_t>,
wchar_t>::iterator]’
/usr/include/c++/13.2.1/format:3581:41:   required from
‘std::__format::_Formatting_scanner<std::__format::_Sink_iter<wchar_t>,
wchar_t>::_M_format_arg(std::size_t)::<lambda(auto:31&)> [with auto:31 = const
void*]’
/usr/include/c++/13.2.1/format:3084:44:   required from ‘decltype(auto)
std::basic_format_arg<_Context>::_M_visit(_Visitor&&, std::__format::_Arg_t)
[with _Visitor =
std::__format::_Formatting_scanner<std::__format::_Sink_iter<wchar_t>,
wchar_t>::_M_format_arg(std::size_t)::<lambda(auto:31&)>; _Context =
std::basic_format_context<std::__format::_Sink_iter<wchar_t>, wchar_t>]’
/usr/include/c++/13.2.1/format:3111:28:   required from ‘decltype(auto)
std::visit_format_arg(_Visitor&&, basic_format_arg<_Context>) [with _Visitor =
__format::_Formatting_scanner<__format::_Sink_iter<wchar_t>,
wchar_t>::_M_format_arg(std::size_t)::<lambda(auto:31&)>; _Context =
basic_format_context<__format::_Sink_iter<wchar_t>, wchar_t>]’
/usr/include/c++/13.2.1/format:3570:23:   required from ‘constexpr void
std::__format::_Formatting_scanner<_Out, _CharT>::_M_format_arg(std::size_t)
[with _Out = std::__format::_Sink_iter<wchar_t>; _CharT = wchar_t; std::size_t
= long unsigned int]’
/usr/include/c++/13.2.1/format:3565:7:   required from here
/usr/include/c++/13.2.1/bits/locale_classes.tcc:200:60: internal compiler
error: in tsubst_copy, at cp/pt.cc:17292                                        
  200 |       if (const _Facet* __f = std::__try_use_facet<_Facet>(__loc))
      |                                                            ^~~~~
0x1ad33c8 internal_error(char const*, ...)
        ???:0
0x6b7b63 fancy_abort(char const*, int, char const*)
        ???:0
0x85da9c tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x85df90 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x85e183 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x85663d instantiate_decl(tree_node*, bool, bool)
        ???:0
0x87ad63 instantiate_pending_templates(int)
        ???:0
0x7714d6 c_parse_final_cleanups()
        ???:0
0x9444b4 c_common_parse_file()
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://bugs.archlinux.org/> for instructions.
```

Outputs of `gcc -v`:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure
--enable-languages=ada,c,c++,d,fortran,go,lto,objc,obj-c++ --enable-bootstrap
--prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--with-build-config=bootstrap-lto --with-linker-hash-style=gnu
--with-system-zlib --enable-__cxa_atexit --enable-cet=auto
--enable-checking=release --enable-clocale=gnu --enable-default-pie
--enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object
--enable-libstdcxx-backtrace --enable-link-serialization=1
--enable-linker-build-id --enable-lto --enable-multilib --enable-plugin
--enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.1 20230801 (GCC)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/112624] Internal compiler error when compiling a module
  2023-11-19 16:44 [Bug c++/112624] New: Internal compiler error when compiling a module amaikinono at gmail dot com
@ 2024-03-26 13:39 ` nshead at gcc dot gnu.org
  2024-03-26 14:52 ` ppalka at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: nshead at gcc dot gnu.org @ 2024-03-26 13:39 UTC (permalink / raw)
  To: gcc-bugs

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

Nathaniel Shead <nshead at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nshead at gcc dot gnu.org

--- Comment #1 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
I haven't been able to reproduce this; it looks like some of the C++ standard
library headers were compiled as importable modules (hence the preprocessed
file including translated 'import' declarations), but apart from <format> and
<string> I'm not sure which other headers have been compiled as such and in
which order.

(It's worth noting that only mod_impl.cpp is relevant here, mod.cxx would not
be used in causing the ICE.)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/112624] Internal compiler error when compiling a module
  2023-11-19 16:44 [Bug c++/112624] New: Internal compiler error when compiling a module amaikinono at gmail dot com
  2024-03-26 13:39 ` [Bug c++/112624] " nshead at gcc dot gnu.org
@ 2024-03-26 14:52 ` ppalka at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-03-26 14:52 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-03-26
                 CC|                            |ppalka at gcc dot gnu.org
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |WAITING

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-26 14:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-19 16:44 [Bug c++/112624] New: Internal compiler error when compiling a module amaikinono at gmail dot com
2024-03-26 13:39 ` [Bug c++/112624] " nshead at gcc dot gnu.org
2024-03-26 14:52 ` ppalka at gcc dot gnu.org

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).