public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98718] New: [modules] use of partitions causes ICE in write_macro_maps
@ 2021-01-18  7:37 boris at kolpackov dot net
  2021-01-18  8:43 ` [Bug c++/98718] " boris at kolpackov dot net
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: boris at kolpackov dot net @ 2021-01-18  7:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98718
           Summary: [modules] use of partitions causes ICE in
                    write_macro_maps
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: boris at kolpackov dot net
  Target Milestone: ---

Created attachment 49988
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49988&action=edit
Reproducer

The attached set of translation units causes an internal compiler error:

hello.mxx:5:9: internal compiler error: in write_macro_maps, at
cp/module.cc:16113
    5 | export module hello;
      |         ^~~~~~
0xc60a67 module_state::write_macro_maps(elf_out*, location_map_info&,
module_state_config*, unsigned int*)
        ../../gcc/gcc/cp/module.cc:16113
0xc659f1 module_state::write(elf_out*, cpp_reader*)
        ../../gcc/gcc/cp/module.cc:17727
0xc6bbfd finish_module_processing(cpp_reader*)
        ../../gcc/gcc/cp/module.cc:19747
0xb8a7a1 c_parse_final_cleanups()
        ../../gcc/gcc/cp/decl2.c:5178
0xf0b805 c_common_parse_file()
        ../../gcc/gcc/c-family/c-opts.c:1233

If I replace std::string with const char* and get rid of the <string>
inclusion, then the ICE disappears. The build transcript is included in the
attached archive.

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

* [Bug c++/98718] [modules] use of partitions causes ICE in write_macro_maps
  2021-01-18  7:37 [Bug c++/98718] New: [modules] use of partitions causes ICE in write_macro_maps boris at kolpackov dot net
@ 2021-01-18  8:43 ` boris at kolpackov dot net
  2021-02-22 15:40 ` nathan at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: boris at kolpackov dot net @ 2021-01-18  8:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Boris Kolpackov <boris at kolpackov dot net> ---
Perhaps this is the same bug but with a simpler reproducer (it points to the
same location):

cat <<EOF >hello-format.mxx
module;

#include <string>

export module hello:format;

namespace hello
{
  export std::string format (const std::string& n)
  {
    return "Hello, " + n + '!';
  }
}
EOF

cat <<EOF >hello.mxx
module;

#include <string>

export module hello;
export import :format;

namespace hello
{
  export void say (const std::string&);
}
EOF

cat <<EOF >mapper.txt
hello hello.gcm
hello:format hello-format.gcm
EOF

g++ -std=c++2a -fmodules-ts -fmodule-mapper=mapper.txt -x c++ -o
hello-format.gcm.o -c hello-format.mxx
g++ -std=c++2a -fmodules-ts -fmodule-mapper=mapper.txt -x c++ -o hello.gcm.o -c
hello.mxx

hello.mxx:5:8: internal compiler error: in write_macro_maps, at
cp/module.cc:16113
    5 | export module hello;
      |        ^~~~~~
0xc60a67 module_state::write_macro_maps(elf_out*, location_map_info&,
module_state_config*, unsigned int*)
        ../../gcc/gcc/cp/module.cc:16113
0xc659f1 module_state::write(elf_out*, cpp_reader*)
        ../../gcc/gcc/cp/module.cc:17727
0xc6bbfd finish_module_processing(cpp_reader*)
        ../../gcc/gcc/cp/module.cc:19747
0xb8a7a1 c_parse_final_cleanups()
        ../../gcc/gcc/cp/decl2.c:5178
0xf0b805 c_common_parse_file()
        ../../gcc/gcc/c-family/c-opts.c:1233

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

* [Bug c++/98718] [modules] use of partitions causes ICE in write_macro_maps
  2021-01-18  7:37 [Bug c++/98718] New: [modules] use of partitions causes ICE in write_macro_maps boris at kolpackov dot net
  2021-01-18  8:43 ` [Bug c++/98718] " boris at kolpackov dot net
@ 2021-02-22 15:40 ` nathan at gcc dot gnu.org
  2021-02-23 18:26 ` nathan at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: nathan at gcc dot gnu.org @ 2021-02-22 15:40 UTC (permalink / raw)
  To: gcc-bugs

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

Nathan Sidwell <nathan at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2021-02-22

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

* [Bug c++/98718] [modules] use of partitions causes ICE in write_macro_maps
  2021-01-18  7:37 [Bug c++/98718] New: [modules] use of partitions causes ICE in write_macro_maps boris at kolpackov dot net
  2021-01-18  8:43 ` [Bug c++/98718] " boris at kolpackov dot net
  2021-02-22 15:40 ` nathan at gcc dot gnu.org
@ 2021-02-23 18:26 ` nathan at gcc dot gnu.org
  2021-02-24 20:46 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: nathan at gcc dot gnu.org @ 2021-02-23 18:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Nathan Sidwell <nathan at gcc dot gnu.org> ---
reduced testcase:

// b_a.ii
module ;

# 4 "inc_a" 1
#define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V)))

namespace std _GLIBCXX_VISIBILITY(default)
{

}
# 11 "" 2

export  module  hello:format;

// b_b.ii
module ;

# 4 "inc_b" 1
#define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V)))
#define _GLIBCXX_BEGIN_NAMESPACE_VERSION 
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
}
# 11 "" 2

export  module  hello;
export  import  :format;
zathras:210>./cc1plus -std=c++20 -fmodules-ts -quiet -fpreprocessed
-fdirectives-only b_a.ii && ./cc1plus -std=c++20 -fmodules-ts -quiet
-fpreprocessed -fdirectives-only b_b.ii
b_b.ii:12:9: internal compiler error: in write_macro_maps, at
cp/module.cc:16154
   12 | export  module  hello;
      |         ^~~~~~
0xce1ab0 module_state::write_macro_maps(elf_out*, location_map_info&,
module_state_config*, unsigned int*)
        ../../../src/gcc/cp/module.cc:16154
0xce662b module_state::write(elf_out*, cpp_reader*)
        ../../../src/gcc/cp/module.cc:17771
0xcec7d8 finish_module_processing(cpp_reader*)
        ../../../src/gcc/cp/module.cc:19860

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

* [Bug c++/98718] [modules] use of partitions causes ICE in write_macro_maps
  2021-01-18  7:37 [Bug c++/98718] New: [modules] use of partitions causes ICE in write_macro_maps boris at kolpackov dot net
                   ` (2 preceding siblings ...)
  2021-02-23 18:26 ` nathan at gcc dot gnu.org
@ 2021-02-24 20:46 ` cvs-commit at gcc dot gnu.org
  2021-02-24 20:47 ` nathan at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-24 20:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Nathan Sidwell <nathan@gcc.gnu.org>:

https://gcc.gnu.org/g:f207eed69e2421695e240aaf47bf881c09cbdd8a

commit r11-7377-gf207eed69e2421695e240aaf47bf881c09cbdd8a
Author: Nathan Sidwell <nathan@acm.org>
Date:   Wed Feb 24 12:32:23 2021 -0800

    c++: Macro location fixes [PR 98718]

    This fixes some issues with macro maps.  We were incorrectly
    calculating the number of macro expansions in a location span, and I
    had a workaround that partially covered that up.  Further, while macro
    location spans are monotonic, that is not true of ordinary location
    spans.  Thus we need to insert an indirection array when binary
    searching the latter. (We load ordinary locations before loading
    imports, but macro locations afterwards.  We make sure an import
    location is de-macrofied, if needed.)

            PR c++/98718
            gcc/cp/
            * module.cc (ool): New indirection vector.
            (loc_spans::maybe_propagate): Location is not optional.
            (loc_spans::open): Likewise.  Assert monotonically advancing.
            (module_for_ordinary_loc): Use ool indirection vector.
            (module_state::write_prepare_maps): Do not count empty macro
            expansions.  Elide empty spans.
            (module_state::write_macro_maps): Skip empty expansions.
            (ool_cmp): New qsort comparator.
            (module_state::write): Create and destroy ool vector.
            (name_pending_imports): Fix dump push/pop.
            (preprocess_module): Likewise.  Add more dumping.
            (preprocessed_module): Likewise.
            libcpp/
            * include/line-map.h
            * line-map.c
            gcc/testsuite/
            * g++.dg/modules/pr98718_a.C: New.
            * g++.dg/modules/pr98718_b.C: New.

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

* [Bug c++/98718] [modules] use of partitions causes ICE in write_macro_maps
  2021-01-18  7:37 [Bug c++/98718] New: [modules] use of partitions causes ICE in write_macro_maps boris at kolpackov dot net
                   ` (3 preceding siblings ...)
  2021-02-24 20:46 ` cvs-commit at gcc dot gnu.org
@ 2021-02-24 20:47 ` nathan at gcc dot gnu.org
  2021-02-26 12:49 ` nathan at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: nathan at gcc dot gnu.org @ 2021-02-24 20:47 UTC (permalink / raw)
  To: gcc-bugs

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

Nathan Sidwell <nathan at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Nathan Sidwell <nathan at gcc dot gnu.org> ---
a13be187cb2 2021-02-24 | c++: modules & -fpreprocessed [PR 99072]

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

* [Bug c++/98718] [modules] use of partitions causes ICE in write_macro_maps
  2021-01-18  7:37 [Bug c++/98718] New: [modules] use of partitions causes ICE in write_macro_maps boris at kolpackov dot net
                   ` (4 preceding siblings ...)
  2021-02-24 20:47 ` nathan at gcc dot gnu.org
@ 2021-02-26 12:49 ` nathan at gcc dot gnu.org
  2021-02-26 12:49 ` nathan at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: nathan at gcc dot gnu.org @ 2021-02-26 12:49 UTC (permalink / raw)
  To: gcc-bugs

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

Nathan Sidwell <nathan at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |alexander.lelyakin@googlema
                   |                            |il.com

--- Comment #5 from Nathan Sidwell <nathan at gcc dot gnu.org> ---
*** Bug 99237 has been marked as a duplicate of this bug. ***

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

* [Bug c++/98718] [modules] use of partitions causes ICE in write_macro_maps
  2021-01-18  7:37 [Bug c++/98718] New: [modules] use of partitions causes ICE in write_macro_maps boris at kolpackov dot net
                   ` (5 preceding siblings ...)
  2021-02-26 12:49 ` nathan at gcc dot gnu.org
@ 2021-02-26 12:49 ` nathan at gcc dot gnu.org
  2021-03-04  7:08 ` boris at kolpackov dot net
  2021-03-05 18:19 ` nathan at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: nathan at gcc dot gnu.org @ 2021-02-26 12:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Nathan Sidwell <nathan at gcc dot gnu.org> ---
*** Bug 99246 has been marked as a duplicate of this bug. ***

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

* [Bug c++/98718] [modules] use of partitions causes ICE in write_macro_maps
  2021-01-18  7:37 [Bug c++/98718] New: [modules] use of partitions causes ICE in write_macro_maps boris at kolpackov dot net
                   ` (6 preceding siblings ...)
  2021-02-26 12:49 ` nathan at gcc dot gnu.org
@ 2021-03-04  7:08 ` boris at kolpackov dot net
  2021-03-05 18:19 ` nathan at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: boris at kolpackov dot net @ 2021-03-04  7:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Boris Kolpackov <boris at kolpackov dot net> ---
Can confirm works for me, thanks!

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

* [Bug c++/98718] [modules] use of partitions causes ICE in write_macro_maps
  2021-01-18  7:37 [Bug c++/98718] New: [modules] use of partitions causes ICE in write_macro_maps boris at kolpackov dot net
                   ` (7 preceding siblings ...)
  2021-03-04  7:08 ` boris at kolpackov dot net
@ 2021-03-05 18:19 ` nathan at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: nathan at gcc dot gnu.org @ 2021-03-05 18:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Nathan Sidwell <nathan at gcc dot gnu.org> ---
*** Bug 99247 has been marked as a duplicate of this bug. ***

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

end of thread, other threads:[~2021-03-05 18:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-18  7:37 [Bug c++/98718] New: [modules] use of partitions causes ICE in write_macro_maps boris at kolpackov dot net
2021-01-18  8:43 ` [Bug c++/98718] " boris at kolpackov dot net
2021-02-22 15:40 ` nathan at gcc dot gnu.org
2021-02-23 18:26 ` nathan at gcc dot gnu.org
2021-02-24 20:46 ` cvs-commit at gcc dot gnu.org
2021-02-24 20:47 ` nathan at gcc dot gnu.org
2021-02-26 12:49 ` nathan at gcc dot gnu.org
2021-02-26 12:49 ` nathan at gcc dot gnu.org
2021-03-04  7:08 ` boris at kolpackov dot net
2021-03-05 18:19 ` nathan 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).