public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "deco33000 at yandex dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/105512] New: compilation with -fmodules-ts and std=c++20 leads to segfault
Date: Sat, 07 May 2022 07:19:08 +0000	[thread overview]
Message-ID: <bug-105512-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 105512
           Summary: compilation with -fmodules-ts and std=c++20 leads to
                    segfault
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: deco33000 at yandex dot com
  Target Milestone: ---

Hi,

compiling with -fmodules-ts and -std=c++20 leads to a segfault. With c++17 no
errors. Without std= switch, no segfault.
But c++20 is required in my code, hence the report.

Here is the reduced code:

----- main.cpp
import hello;

int main ( void ){

        X::greeter("ok");
        return 0;
}

-----mod.cxx
module;

#include <iostream>
#include <string_view>
#include <string>

export module hello;
import sub_mod;

namespace X {

                void greeter2 ( std::string_view const &name ){
                        std::string h = "exported greeter";

                        std::cout << "Bye " << name << "!" << h << "\n";
                        Y::g();

                }

        }

export {

        namespace X {

                void greeter ( std::string_view const &name ){
                        std::string h = "exported greeter";

                        std::cout << "Hello " << name << "!" << h << "\n";

                        greeter2("ff");
                }

        }
}

-----mod_sub.cxx
module;

#include <iostream>
export module sub_mod;

export {
        namespace Y {

                auto g (){

                        std::cout << "in out " << std::endl;

                }

        }
}

The following works with c++17 and c++20 flags (no issue):

----- mod_sub.cxx corrected (no global fragment):
export module sub_mod;

export {
        namespace Y {

                auto g ()-> int{

                        //std::cout << "in out " << std::endl;
                        return 54;

                }

        }
}

and

----- mod.cxx corrected (prints g() directly):
module;

#include <iostream>
#include <string_view>
#include <string>

export module hello;
import sub_mod;

namespace X {

                void greeter2 ( std::string_view const &name ){
                        std::string h = "exported greeter";

                        std::cout << "Bye " << name << "!" << h << " " <<
Y::g() <<"\n";


                }

        }

export {

        namespace X {

                void greeter ( std::string_view const &name ){
                        std::string h = "exported greeter";

                        std::cout << "Hello " << name << "!" << h << "\n";

                        greeter2("ff");
                }

        }
}

Thanks,

             reply	other threads:[~2022-05-07  7:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-07  7:19 deco33000 at yandex dot com [this message]
2023-06-18 18:02 ` [Bug c++/105512] " gnu.w2nnu at simplelogin dot com
2023-09-08 20:12 ` mail@gerrit-albrecht.de
2024-03-06 21:26 ` ppalka at gcc dot gnu.org
2024-03-07 21:24 ` cvs-commit at gcc dot gnu.org
2024-03-07 21:25 ` 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-105512-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).