public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98843] New: Building simple c++ modules example fails but successful with -save-temps
@ 2021-01-26 23:35 gcc at boltav dot me.uk
  2021-01-26 23:46 ` [Bug c++/98843] " gcc at boltav dot me.uk
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: gcc at boltav dot me.uk @ 2021-01-26 23:35 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98843
           Summary: Building simple c++ modules example fails but
                    successful with -save-temps
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc at boltav dot me.uk
  Target Milestone: ---

Checked out and built:
g++ (GCC) 11.0.0 20210125 (experimental)
@ commit a61efd469371b71483d42afa1038e6a8c16baf4a (HEAD -> master,
origin/master, origin/HEAD)

When I try to build the sources below, the build fails.  However when I added
-save-temps for this bug report the build succeeded!

sources below from https://vector-of-bool.github.io/2019/03/10/modules-1.html

source - mod.cpp

export module speech;
export const char* get_phrase() {
    return "Hello, world!";
}

source - main.cpp

// main.cpp
import speech;
import <iostream>;
int main() {
    std::cout << get_phrase() << '\n';
}

Commands for build:

g++ --version
g++ -c -std=c++20 -fmodules-ts -o mod.o ../src/mod.cpp
g++  -std=c++20 -fmodules-ts -x c++-system-header iostream
g++ -c -std=c++20 -fmodules-ts -o main.o ../src/main.cpp

Diagnostic:

g++ (GCC) 11.0.0 20210125 (experimental)
Copyright © 2021 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.

‘
In file included from
/home/gary/Projects/g++mod/install/20210125/include/c++/11.0.0/bits/ios_base.h:46,
                 from
/home/gary/Projects/g++mod/install/20210125/include/c++/11.0.0/ios:42,
                 from
/home/gary/Projects/g++mod/install/20210125/include/c++/11.0.0/ostream:38,
                 from
/home/gary/Projects/g++mod/install/20210125/include/c++/11.0.0/iostream:39,
of module
/home/gary/Projects/g++mod/install/20210125/include/c++/11.0.0/iostream,
imported at /home/gary/Projects/module-test/builds/../src/main.cpp:4:
in import_entity_module, at cp/module.cc:4083
  189 |     template<typename _ErrorCodeEnum, typename = typename
      |                                       ^~~~~~~~
0x82e83c import_entity_module
        /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/module.cc:4083
0x841640 get_importing_module(tree_node*, bool)
        /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/module.cc:18348
0x7d0026 dump_module_suffix
        /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/error.c:205
0x7d0f1a dump_module_suffix
        /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/error.c:187
0x7d0f1a dump_aggr_type
        /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/error.c:806
0x7dc609 dump_function_decl
        /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/error.c:1717
0x7df417 subst_to_string
        /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/error.c:3384
0x7df417 cp_printer
        /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/error.c:4376
0x1d000f1 pp_format(pretty_printer*, text_info*)
        /home/gary/Repo/GitRepo/g++with-mod/gcc/pretty-print.c:1475
0x1d00770 pp_format_verbatim(pretty_printer*, text_info*)
        /home/gary/Repo/GitRepo/g++with-mod/gcc/pretty-print.c:1536
0x1d00851 pp_verbatim(pretty_printer*, char const*, ...)
        /home/gary/Repo/GitRepo/g++with-mod/gcc/pretty-print.c:1790
0x7cfd0f print_instantiation_full_context
        /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/error.c:3589
0x7e0652 maybe_print_instantiation_context
        /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/error.c:3737
0x7e0652 cp_diagnostic_starter
        /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/error.c:3428
0x1ce2de6 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
        /home/gary/Repo/GitRepo/g++with-mod/gcc/diagnostic.c:1245
0x1ce340e diagnostic_impl
        /home/gary/Repo/GitRepo/g++with-mod/gcc/diagnostic.c:1406
0x1ce4259 internal_error(char const*, ...)
        /home/gary/Repo/GitRepo/g++with-mod/gcc/diagnostic.c:1808
0x6b6a8b fancy_abort(char const*, int, char const*)
        /home/gary/Repo/GitRepo/g++with-mod/gcc/diagnostic.c:1907
0x82e83c import_entity_module
        /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/module.cc:4083
0x865df2 pendset_lazy_load
        /home/gary/Repo/GitRepo/g++with-mod/gcc/cp/module.cc:13669
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.


Build dir layout after (because modules):

$ tree
.
├── gcm.cache
│   ├── home
│   │   └── gary
│   │       └── Projects
│   │           └── g++mod
│   │               └── install
│   │                   └── 20210125
│   │                       └── include
│   │                           └── c++
│   │                               └── 11.0.0
│   │                                   └── iostream.gcm
│   └── speech.gcm
├── mod.o
└── mods.sh

System:
Linux 5.4.0-64-generic #72~18.04.1-Ubuntu SMP Fri Jan 15 14:06:34 UTC 2021
x86_64 x86_64 x86_64 GNU/Linux

Version and options:

→ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-7
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)

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

* [Bug c++/98843] Building simple c++ modules example fails but successful with -save-temps
  2021-01-26 23:35 [Bug c++/98843] New: Building simple c++ modules example fails but successful with -save-temps gcc at boltav dot me.uk
@ 2021-01-26 23:46 ` gcc at boltav dot me.uk
  2021-01-27 12:47 ` nathan at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: gcc at boltav dot me.uk @ 2021-01-26 23:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from gazzatav <gcc at boltav dot me.uk> ---
Created attachment 50064
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50064&action=edit
mod.ii, main.ii - tmp files required by guidelines, a-iostream.ii too large

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

* [Bug c++/98843] Building simple c++ modules example fails but successful with -save-temps
  2021-01-26 23:35 [Bug c++/98843] New: Building simple c++ modules example fails but successful with -save-temps gcc at boltav dot me.uk
  2021-01-26 23:46 ` [Bug c++/98843] " gcc at boltav dot me.uk
@ 2021-01-27 12:47 ` nathan at gcc dot gnu.org
  2021-01-29 17:22 ` cvs-commit at gcc dot gnu.org
  2021-01-29 17:23 ` nathan at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: nathan at gcc dot gnu.org @ 2021-01-27 12:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Nathan Sidwell <nathan at gcc dot gnu.org> ---
thanks Gary, I expect to be able to reprduce the iostream.ii myself, and
particularly as (the lack of) -save-temps seems to be significant, I'll
probably need to.

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

* [Bug c++/98843] Building simple c++ modules example fails but successful with -save-temps
  2021-01-26 23:35 [Bug c++/98843] New: Building simple c++ modules example fails but successful with -save-temps gcc at boltav dot me.uk
  2021-01-26 23:46 ` [Bug c++/98843] " gcc at boltav dot me.uk
  2021-01-27 12:47 ` nathan at gcc dot gnu.org
@ 2021-01-29 17:22 ` cvs-commit at gcc dot gnu.org
  2021-01-29 17:23 ` nathan at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-29 17:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- 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:83bdc9f70347e6438822e719c30c3793c81df18e

commit r11-6983-g83bdc9f70347e6438822e719c30c3793c81df18e
Author: Nathan Sidwell <nathan@acm.org>
Date:   Fri Jan 29 08:30:40 2021 -0800

    c++: Fix unordered entity array [PR 98843]

    A couple of module invariants are that the modules are always
    allocated in ascending order and appended to the module array.  The
    entity array is likewise ordered, with each module having spans in
    that array in ascending order.  Prior to header-units, this was
    provided by the way import declarations were encountered.  With
    header-units we need to load the preprocessor state of header units
    before we parse the C++, and this can lead to incorrect ordering of
    the entity array.  I had made the initialization of a module's
    language state a little too lazy.  This moves the allocation of entity
    array spans into the initial read of a module, thus ensuring the
    ordering of those spans.  We won't be looking in them until we've
    loaded the language portions of that particular module, and even if we
    did, we'd find NULLs there and issue a diagnostic.

            PR c++/98843
            gcc/cp/
            * module.cc (module_state_config): Add num_entities field.
            (module_state::read_entities): The entity_ary span is
            already allocated.
            (module_state::write_config): Write num_entities.
            (module_state::read_config): Read num_entities.
            (module_state::write): Set config's num_entities.
            (module_state::read_initial): Allocate the entity ary
            span here.
            (module_state::read_language): Do not set entity_lwm
            here.
            gcc/testsuite/
            * g++.dg/modules/pr98843_a.C: New.
            * g++.dg/modules/pr98843_b.H: New.
            * g++.dg/modules/pr98843_c.C: New.

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

* [Bug c++/98843] Building simple c++ modules example fails but successful with -save-temps
  2021-01-26 23:35 [Bug c++/98843] New: Building simple c++ modules example fails but successful with -save-temps gcc at boltav dot me.uk
                   ` (2 preceding siblings ...)
  2021-01-29 17:22 ` cvs-commit at gcc dot gnu.org
@ 2021-01-29 17:23 ` nathan at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: nathan at gcc dot gnu.org @ 2021-01-29 17:23 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #4 from Nathan Sidwell <nathan at gcc dot gnu.org> ---
83bdc9f7034 2021-01-29 | c++: Fix unordered entity array [PR 98843]

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

end of thread, other threads:[~2021-01-29 17:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-26 23:35 [Bug c++/98843] New: Building simple c++ modules example fails but successful with -save-temps gcc at boltav dot me.uk
2021-01-26 23:46 ` [Bug c++/98843] " gcc at boltav dot me.uk
2021-01-27 12:47 ` nathan at gcc dot gnu.org
2021-01-29 17:22 ` cvs-commit at gcc dot gnu.org
2021-01-29 17:23 ` 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).