public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105512] New: compilation with -fmodules-ts and std=c++20 leads to segfault
@ 2022-05-07  7:19 deco33000 at yandex dot com
  2023-06-18 18:02 ` [Bug c++/105512] " gnu.w2nnu at simplelogin dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: deco33000 at yandex dot com @ 2022-05-07  7:19 UTC (permalink / raw)
  To: gcc-bugs

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,

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

end of thread, other threads:[~2024-03-07 21:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-07  7:19 [Bug c++/105512] New: compilation with -fmodules-ts and std=c++20 leads to segfault deco33000 at yandex dot com
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

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