public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/115257] New: Error when compiling a program with module and println and auto
@ 2024-05-28 10:47 paalon1936 at gmail dot com
  2024-06-01  2:10 ` [Bug c++/115257] " nshead at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: paalon1936 at gmail dot com @ 2024-05-28 10:47 UTC (permalink / raw)
  To: gcc-bugs

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.

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

* [Bug c++/115257] Error when compiling a program with module and println and auto
  2024-05-28 10:47 [Bug c++/115257] New: Error when compiling a program with module and println and auto paalon1936 at gmail dot com
@ 2024-06-01  2:10 ` nshead at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: nshead at gcc dot gnu.org @ 2024-06-01  2:10 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nshead at gcc dot gnu.org
         Resolution|---                         |DUPLICATE
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Looks to be the same issue as PR114275, fixed on trunk.

*** This bug has been marked as a duplicate of bug 114275 ***

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

end of thread, other threads:[~2024-06-01  2:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-28 10:47 [Bug c++/115257] New: Error when compiling a program with module and println and auto paalon1936 at gmail dot com
2024-06-01  2:10 ` [Bug c++/115257] " nshead 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).