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

            Bug ID: 112588
           Summary: ICE in make_decl_rtl when returning str literal when
                    string header imported in module
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nickbegg at gmail dot com
  Target Milestone: ---

Created attachment 56622
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56622&action=edit
-freport-bug output

/home/nick/gcc-trunk-debug-inst/include/c++/14.0.0/bits/allocator.h:191:39:
internal compiler error: in make_decl_rtl, at varasm.cc:1442
  191 |             if (__builtin_mul_overflow(__n, sizeof(_Tp), &__n))
      |                 ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

Using when importing a module into a non-module TU, #including string in both
causes an ICE when returning a string literal in a function with std::string
return type -

////////////////////////
// modA.mpp (compiled as module):

module;

#include <string>

export module modA;

///////////////////////
// main.cpp (compiled as regular TU): 

#include <string>

import modA;

std::string test_func() {
    return "foo";
}

int main() {
    return 0;
}
///////////////////////

The ICE happens when compiling main.cpp.

Removing the import from main.cpp, or returning std::string() from test_func()
stops the ICE. 

GCC trunk (14) version, git rev ba3f5b8465ef7b278ea33ff94cd85b9638058635

Reply via email to