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

            Bug ID: 115257
           Summary: Error when compiling a program with module and println
                    and auto
           Product: gcc
           Version: 14.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: paalon1936 at gmail dot com
  Target Milestone: ---

When I tried to make a following program with module and <print> and autos,
failed to compile.

$ g++-14 -std=c++23 -fmodules-ts -x c++-system-header print
$ g++-14 -std=c++23 -fmodules-ts -Wall -Wextra -save-temps hello.cpp main.cpp
-o main
In file included from /usr/local/Cellar/gcc/14.1.0/include/c++/14/print:41,
of module /usr/local/Cellar/gcc/14.1.0/include/c++/14/print, imported at
hello.cpp:3,
of module hello, imported at main.cpp:1:
/usr/local/Cellar/gcc/14.1.0/include/c++/14/format: In instantiation of 'struct
std::__format::_Runtime_format_string<char>':
/usr/local/Cellar/gcc/14.1.0/include/c++/14/print:129:19:   required from 'void
std::println(format_string<_Args ...>, _Args&& ...) [with _Args = {const char
(&)[4]}; format_string<_Args ...> = basic_format_string<char, const char
(&)[4]>]'
  129 |     { std::println(stdout, __fmt, std::forward<_Args>(__args)...); }
      |       ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hello.cpp:7:21:   required from 'auto hello::greeting@hello(const auto:1&)
[with auto:1 = char [4]]'
    7 |         std::println("Hello, {}!", x);
      |         ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
main.cpp:4:20:   required from here
    4 |     hello::greeting("C++");
      |     ~~~~~~~~~~~~~~~^~~~~~~
/usr/local/Cellar/gcc/14.1.0/include/c++/14/format:74:55: internal compiler
error: Segmentation fault: 11
   74 |   template<typename _CharT, typename... _Args> struct
basic_format_string;
      |                                                      
^~~~~~~~~~~~~~~~~~~
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
See <https://github.com/Homebrew/homebrew-core/issues> for instructions.
$ cat main-hello.ii
# 0 "hello.cpp"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "hello.cpp"
export  module  hello;

import  "/usr/local/Cellar/gcc/14.1.0/include/c++/14/print";

export namespace hello {
    auto greeting(auto const & x) {
        std::println("Hello, {}!", x);
    }
}
$ cat main-main.ii
# 0 "main.cpp"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "main.cpp"
import  hello;

int main() {
    hello::greeting("C++");
}

If I don't use module, but use `#include` then it works, and
if I don't use std::println of <print> and use std::cout of <iostream>, then it
works, and
if I don't use autos, and specify the types `void` and `char const *`, then it
works.

I'm using macOS Ventura 13.6.7, and GCC 14.1.0.
$ g++-14 --version
g++-14 (Homebrew GCC 14.1.0) 14.1.0
Copyright (C) 2024 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.

Reply via email to