* [Bug c++/100134] [modules] ICE when using a vector in a module
2021-04-18 9:48 [Bug c++/100134] New: ICE when using a vector in a mdoule patrick.kox at commandoregel dot be
@ 2021-06-20 9:03 ` ensadc at mailnesia dot com
2022-03-10 14:49 ` sandipan.mohanty at gmail dot com
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: ensadc at mailnesia dot com @ 2021-06-20 9:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100134
--- Comment #1 from ensadc at mailnesia dot com ---
Reduced:
========
vector
--------
namespace std {
template <typename _Tp, typename _Up> struct __replace_first_arg;
template <template <typename, typename...> class _Template, typename _Up,
typename _Tp, typename... _Types>
struct __replace_first_arg<_Template<_Tp, _Types...>, _Up> {
using type = _Template<_Up, _Types...>;
};
template <typename _Tp> struct allocator {
typedef _Tp value_type;
friend constexpr bool operator==(const allocator &,
const allocator &) noexcept {
return true;
}
};
} // namespace std
namespace __gnu_cxx {
template <typename _Alloc, typename = typename _Alloc::value_type>
struct __alloc_traits {
template <typename _Tp> struct rebind {
typedef std::__replace_first_arg<_Alloc, _Tp> other;
};
};
} // namespace __gnu_cxx
namespace std {
template <typename _Tp, typename _Alloc = std::allocator<_Tp>> class vector {
typedef
typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind<_Tp>::other
_Tp_alloc_type;
};
} // namespace std
========
foo.cpp
--------
export module foo;
import <vector>;
export struct Foo {
std::vector<int> v;
};
========
build commands:
g++ -I . -x c++-system-header -fmodules-ts -std=c++20 vector
g++ -I . -std=c++20 -fmodules-ts foo.cpp
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/100134] [modules] ICE when using a vector in a module
2021-04-18 9:48 [Bug c++/100134] New: ICE when using a vector in a mdoule patrick.kox at commandoregel dot be
2021-06-20 9:03 ` [Bug c++/100134] [modules] ICE when using a vector in a module ensadc at mailnesia dot com
@ 2022-03-10 14:49 ` sandipan.mohanty at gmail dot com
2022-04-06 7:47 ` sandipan.mohanty at gmail dot com
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: sandipan.mohanty at gmail dot com @ 2022-03-10 14:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100134
Sandipan Mohanty <sandipan.mohanty at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |sandipan.mohanty at gmail dot com
--- Comment #2 from Sandipan Mohanty <sandipan.mohanty at gmail dot com> ---
I was about to report something very similar, so I will add my observations to
this report:
(i) I have reproduced this after pulling and rebuilding today (10 March 2022)
from gcc git repository. The commit id for my testing version is
3357878ef56d1e47666fc697cfd7cb5cd9c1dfc9.
(ii) The ICE happens even if you don't create a vector instance:
// minimal code to reproduce
module;
import <vector>;
export module SomeModule;
struct SomeClass {
using iterator = std::vector<int>::iterator;
};
// end code
Compilation steps are as in the original report. In order to avoid possible
interference from other header units, I performed each of my tests by first
removing gcm.cache/.
$ rm -rf gcm.cache
$ g++ -std=c++20 -fmodules-ts -xc++-system-header vector
$ g++ -std=c++20 -fmodules-ts -c module_ICE_1.cc -freport-bug
(iii) One can change vector to deque, list, forward_list or a set, and still
have the same error. Changing the container to std::array does not cause this
specific ICE.
(iv) Replacing the container with std::map<int, int> still has the same error,
but std::unordered_map<int, int> does not! With an unordered_set, one can get
further and create objects in the module.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/100134] [modules] ICE when using a vector in a module
2021-04-18 9:48 [Bug c++/100134] New: ICE when using a vector in a mdoule patrick.kox at commandoregel dot be
2021-06-20 9:03 ` [Bug c++/100134] [modules] ICE when using a vector in a module ensadc at mailnesia dot com
2022-03-10 14:49 ` sandipan.mohanty at gmail dot com
@ 2022-04-06 7:47 ` sandipan.mohanty at gmail dot com
2022-04-06 7:52 ` sandipan.mohanty at gmail dot com
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: sandipan.mohanty at gmail dot com @ 2022-04-06 7:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100134
--- Comment #3 from Sandipan Mohanty <sandipan.mohanty at gmail dot com> ---
Created attachment 52759
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52759&action=edit
Preprocessed source generated by gcc
Preprocessed source generated by gcc
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/100134] [modules] ICE when using a vector in a module
2021-04-18 9:48 [Bug c++/100134] New: ICE when using a vector in a mdoule patrick.kox at commandoregel dot be
` (2 preceding siblings ...)
2022-04-06 7:47 ` sandipan.mohanty at gmail dot com
@ 2022-04-06 7:52 ` sandipan.mohanty at gmail dot com
2022-09-26 23:33 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: sandipan.mohanty at gmail dot com @ 2022-04-06 7:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100134
--- Comment #4 from Sandipan Mohanty <sandipan.mohanty at gmail dot com> ---
Comment on attachment 52759
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52759
Preprocessed source generated by gcc
This bug remains unhandled as of 6 April 2022, making it difficult to use
modules at all with gcc. The attachment is the preprocessed source generated by
gcc for the minimized example in my previous comment. The ICE continues to
happen when using a freshly compiled gcc after pulling from git on 6 April
2022. git commit id: 9d84ed6812dce4a50e64334e7cc4abdeebe41523
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/100134] [modules] ICE when using a vector in a module
2021-04-18 9:48 [Bug c++/100134] New: ICE when using a vector in a mdoule patrick.kox at commandoregel dot be
` (3 preceding siblings ...)
2022-04-06 7:52 ` sandipan.mohanty at gmail dot com
@ 2022-09-26 23:33 ` pinskia at gcc dot gnu.org
2022-09-26 23:34 ` johelegp at gmail dot com
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-09-26 23:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100134
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |johelegp at gmail dot com
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 107045 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/100134] [modules] ICE when using a vector in a module
2021-04-18 9:48 [Bug c++/100134] New: ICE when using a vector in a mdoule patrick.kox at commandoregel dot be
` (4 preceding siblings ...)
2022-09-26 23:33 ` pinskia at gcc dot gnu.org
@ 2022-09-26 23:34 ` johelegp at gmail dot com
2022-10-07 19:11 ` ppalka at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: johelegp at gmail dot com @ 2022-09-26 23:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100134
--- Comment #6 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107045#c1 for a minimal
reproducer:
Minimal: https://godbolt.org/z/hxrPvPPhs.
```C++
namespace std {
template<class> struct X {
friend void f();
};
}
```
```C++
export module mod;
import "std.hpp";
export std::X<int> v;
```
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/100134] [modules] ICE when using a vector in a module
2021-04-18 9:48 [Bug c++/100134] New: ICE when using a vector in a mdoule patrick.kox at commandoregel dot be
` (5 preceding siblings ...)
2022-09-26 23:34 ` johelegp at gmail dot com
@ 2022-10-07 19:11 ` ppalka at gcc dot gnu.org
2022-10-11 19:03 ` cvs-commit at gcc dot gnu.org
2022-10-12 14:36 ` ppalka at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-10-07 19:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100134
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2022-10-07
Keywords| |ice-on-valid-code
Ever confirmed|0 |1
CC| |ppalka at gcc dot gnu.org
--- Comment #7 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Adding 'namespace std { }' alongside the exported entity seems to be a
workaround, e.g.
export module mod;
import "std.hpp";
namespace std { }
export std::X<int> v;
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/100134] [modules] ICE when using a vector in a module
2021-04-18 9:48 [Bug c++/100134] New: ICE when using a vector in a mdoule patrick.kox at commandoregel dot be
` (6 preceding siblings ...)
2022-10-07 19:11 ` ppalka at gcc dot gnu.org
@ 2022-10-11 19:03 ` cvs-commit at gcc dot gnu.org
2022-10-12 14:36 ` ppalka at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-10-11 19:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100134
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:9736a42e1fb8df30d72cf28594d9046bf50200c1
commit r13-3236-g9736a42e1fb8df30d72cf28594d9046bf50200c1
Author: Patrick Palka <ppalka@redhat.com>
Date: Tue Oct 11 15:02:23 2022 -0400
c++ modules: ICE with templated friend and std namespace [PR100134]
The function depset::hash::add_binding_entity has an assert verifying
that if a namespace contains an exported entity, then the namespace must
have been opened in the module purview:
if (data->hash->add_namespace_entities (decl, data->partitions))
{
/* It contains an exported thing, so it is exported. */
gcc_checking_assert (DECL_MODULE_PURVIEW_P (decl));
DECL_MODULE_EXPORT_P (decl) = true;
}
We're tripping over this assert in the below testcase because by
instantiating and exporting std::A<int>, we in turn define and export the
hidden friend std::f(A<int>) without ever having opened the enclosing
namespace std within the module purview, and thus DECL_MODULE_PURVIEW_P
for std is false.
It's important that the enclosing namespace is std here: if we use
a different namespace then the ICE disappears. This probably has
something to do with us predefining std via push_namespace from
cxx_init_decl_processing (which makes it look like we've opened it
within the TU), whereas with another namespace we would instead lazily
create its NAMESPACE_DECL from add_imported_namespace.
Since templated friend functions are special in that they give us a way
to introduce a namespace-scope function without having to explicitly
open the namespace, this patch proposes to fix this ICE by propagating
DECL_MODULE_PURVIEW_P from the introduced function to the enclosing
namespace during tsubst_friend_function.
PR c++/100134
gcc/cp/ChangeLog:
* pt.cc (tsubst_friend_function): Propagate DECL_MODULE_PURVIEW_P
from the introduced namespace-scope function to the namespace.
gcc/testsuite/ChangeLog:
* g++.dg/modules/tpl-friend-8_a.H: New test.
* g++.dg/modules/tpl-friend-8_b.C: New test.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/100134] [modules] ICE when using a vector in a module
2021-04-18 9:48 [Bug c++/100134] New: ICE when using a vector in a mdoule patrick.kox at commandoregel dot be
` (7 preceding siblings ...)
2022-10-11 19:03 ` cvs-commit at gcc dot gnu.org
@ 2022-10-12 14:36 ` ppalka at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-10-12 14:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100134
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |13.0
Status|NEW |RESOLVED
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
Resolution|--- |FIXED
--- Comment #9 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Should be fixed on trunk
^ permalink raw reply [flat|nested] 10+ messages in thread