* [Bug c++/107033] [13 Regression] [modules] ICE converting to span
2022-09-25 14:08 [Bug c++/107033] New: [13 Regression] [modules] ICE converting to span johelegp at gmail dot com
@ 2022-09-25 16:08 ` johelegp at gmail dot com
2022-09-25 16:09 ` johelegp at gmail dot com
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: johelegp at gmail dot com @ 2022-09-25 16:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107033
Johel Ernesto Guerrero Peña <johelegp at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-valid-code
Known to fail| |11.3.0, 12.2.0
--- Comment #1 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
Simplified. GCC12 only accepts when the span is an lvalue, and otherwise is
rejects-valid. GCC11 and GCC13 are ice-on-valid-code with different backtraces.
GCC11: https://godbolt.org/z/ev5Wb4d3v
GCC12: https://godbolt.org/z/bo6f5nT7Y
GCC13: https://godbolt.org/z/qGdWq4383
GCC12 lvalue: https://godbolt.org/z/zoz69ener
GCC11:
```
In file included from /app/std.hpp:2,
of module /app/std.hpp, imported at /app/mod.cpp:2:
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/span: In instantiation of
'class std::span<int>':
mod.cpp:3:51: required from here
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/span:155:9: internal
compiler error: Segmentation fault
155 | span(_It __first, size_type __count)
| ^~~~
0x17888c9 internal_error(char const*, ...)
???:0
0x7da897 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x7f6feb instantiate_class_template(tree_node*)
???:0
0x82a7f3 complete_type(tree_node*)
???:0
0x806c31 finish_compound_literal(tree_node*, tree_node*, int, fcl_t)
???:0
0x7c123b c_parse_file()
???:0
0x894042 c_common_parse_file()
???:0
```
GCC12:
```
mod.cpp:3:35: error: no match for call to '(const
std::ranges::__cust_access::_Begin) (std::span<int>)'
3 | export auto _ = std::ranges::begin(std::span<int>{});
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
In file included from
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/string_view:50,
from
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/basic_string.h:47,
from
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/string:53,
from
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/locale_classes.h:40,
from
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/ios_base.h:41,
from
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/streambuf:41,
from
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/streambuf_iterator.h:35,
from
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/iterator:66,
from
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/ranges:43,
from /app/std.hpp:1,
of module /app/std.hpp, imported at /app/mod.cpp:2:
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/ranges_base.h:114:9:
note: candidate: 'template<class _Tp> requires (__maybe_borrowed_range<_Tp>)
&& ((is_array_v<typename std::remove_reference<_Tp>::type>) ||
(__member_begin<_Tp>) || (__adl_begin<_Tp>)) constexpr auto
std::ranges::__cust_access::_Begin::operator()(_Tp&&) const'
114 | operator()[[nodiscard]](_Tp&& __t) const
noexcept(_S_noexcept<_Tp&>())
| ^~~~~~~~
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/ranges_base.h:114:9:
note: template argument deduction/substitution failed:
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/ranges_base.h:114:9:
note: constraints not satisfied
mod.cpp: In substitution of 'template<class _Tp> requires
(__maybe_borrowed_range<_Tp>) && ((is_array_v<typename
std::remove_reference<_Tp>::type>) || (__member_begin<_Tp>) ||
(__adl_begin<_Tp>)) constexpr auto
std::ranges::__cust_access::_Begin::operator()(_Tp&&) const [with _Tp =
std::span<int>]':
mod.cpp:3:35: required from here
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/ranges_base.h:83:15:
required for the satisfaction of '__maybe_borrowed_range<_Tp>' [with _Tp =
std::span<int, 18446744073709551615>]
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/ranges_base.h:85:11:
note: no operand of the disjunction is satisfied
84 | = is_lvalue_reference_v<_Tp>
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
85 | || enable_borrowed_range<remove_cvref_t<_Tp>>;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: note: set '-fconcepts-diagnostics-depth=' to at least 2 for more
detail
mod.cpp:1:8: warning: not writing module 'mod' due to errors
1 | export module mod;
| ^~~~~~
```
GCC13:
```
mod.cpp:1:8: internal compiler error: Segmentation fault
1 | export module mod;
| ^~~~~~
0x234bd6e internal_error(char const*, ...)
???:0
0xc84cfe walk_specializations(bool, void (*)(bool, spec_entry*, void*), void*)
???:0
0xbead4c depset::hash::add_specializations(bool)
???:0
0xbfb5a8 module_state::write_begin(elf_out*, cpp_reader*, module_state_config&,
unsigned int&)
???:0
0xbfcd45 finish_module_processing(cpp_reader*)
???:0
0xb89d2e c_parse_final_cleanups()
???:0
0xdb0cc8 c_common_parse_file()
???:0
```
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/107033] [13 Regression] [modules] ICE converting to span
2022-09-25 14:08 [Bug c++/107033] New: [13 Regression] [modules] ICE converting to span johelegp at gmail dot com
2022-09-25 16:08 ` [Bug c++/107033] " johelegp at gmail dot com
@ 2022-09-25 16:09 ` johelegp at gmail dot com
2022-09-25 16:32 ` [Bug c++/107033] [13 Regression] [modules] ICE using span as a range johelegp at gmail dot com
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: johelegp at gmail dot com @ 2022-09-25 16:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107033
--- Comment #2 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
Does it count as a regression if rejects-valid becomes ice-on-valid-code? IIRC,
~3 weeks ago the lvalue case was rejects-valid, like GCC12.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/107033] [13 Regression] [modules] ICE using span as a range
2022-09-25 14:08 [Bug c++/107033] New: [13 Regression] [modules] ICE converting to span johelegp at gmail dot com
2022-09-25 16:08 ` [Bug c++/107033] " johelegp at gmail dot com
2022-09-25 16:09 ` johelegp at gmail dot com
@ 2022-09-25 16:32 ` johelegp at gmail dot com
2022-09-25 17:12 ` johelegp at gmail dot com
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: johelegp at gmail dot com @ 2022-09-25 16:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107033
--- Comment #3 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
Simplified: https://godbolt.org/z/3Ys316aeE.
```C++
export module mod;
import "std.hpp";
int x[2];
export auto _ = std::ranges::begin(x);
```
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/107033] [13 Regression] [modules] ICE using span as a range
2022-09-25 14:08 [Bug c++/107033] New: [13 Regression] [modules] ICE converting to span johelegp at gmail dot com
` (2 preceding siblings ...)
2022-09-25 16:32 ` [Bug c++/107033] [13 Regression] [modules] ICE using span as a range johelegp at gmail dot com
@ 2022-09-25 17:12 ` johelegp at gmail dot com
2022-09-26 9:27 ` [Bug c++/107033] [13 Regression] [modules] Variable template of type trait via importable header gives wrong result rguenth at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: johelegp at gmail dot com @ 2022-09-25 17:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107033
--- Comment #4 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
This is actually Bug 106826.
Simplest: https://godbolt.org/z/oKT4x9r4G.
```C++
template<class> constexpr bool is = false;
template<class T> constexpr bool is<T&> = true;
```
```C++
export module mod;
import "std.hpp";
static_assert(is<int&>);
```
```
mod.cpp:1:8: internal compiler error: Segmentation fault
1 | export module mod;
| ^~~~~~
0x234bd6e internal_error(char const*, ...)
???:0
0xc84cfe walk_specializations(bool, void (*)(bool, spec_entry*, void*), void*)
???:0
0xbead4c depset::hash::add_specializations(bool)
???:0
0xbfb5a8 module_state::write_begin(elf_out*, cpp_reader*, module_state_config&,
unsigned int&)
???:0
0xbfcd45 finish_module_processing(cpp_reader*)
???:0
0xb89d2e c_parse_final_cleanups()
???:0
0xdb0cc8 c_common_parse_file()
???:0
```
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/107033] [13 Regression] [modules] Variable template of type trait via importable header gives wrong result
2022-09-25 14:08 [Bug c++/107033] New: [13 Regression] [modules] ICE converting to span johelegp at gmail dot com
` (3 preceding siblings ...)
2022-09-25 17:12 ` johelegp at gmail dot com
@ 2022-09-26 9:27 ` rguenth at gcc dot gnu.org
2022-09-26 13:07 ` ppalka at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-09-26 9:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107033
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |13.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/107033] [13 Regression] [modules] Variable template of type trait via importable header gives wrong result
2022-09-25 14:08 [Bug c++/107033] New: [13 Regression] [modules] ICE converting to span johelegp at gmail dot com
` (4 preceding siblings ...)
2022-09-26 9:27 ` [Bug c++/107033] [13 Regression] [modules] Variable template of type trait via importable header gives wrong result rguenth at gcc dot gnu.org
@ 2022-09-26 13:07 ` ppalka at gcc dot gnu.org
2022-09-26 15:31 ` cvs-commit at gcc dot gnu.org
2022-09-29 21:07 ` ppalka at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-09-26 13:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107033
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2022-09-26
Status|UNCONFIRMED |ASSIGNED
CC| |ppalka at gcc dot gnu.org
Ever confirmed|0 |1
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
D'oh, thanks for the report.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/107033] [13 Regression] [modules] Variable template of type trait via importable header gives wrong result
2022-09-25 14:08 [Bug c++/107033] New: [13 Regression] [modules] ICE converting to span johelegp at gmail dot com
` (5 preceding siblings ...)
2022-09-26 13:07 ` ppalka at gcc dot gnu.org
@ 2022-09-26 15:31 ` cvs-commit at gcc dot gnu.org
2022-09-29 21:07 ` ppalka at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-09-26 15:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107033
--- Comment #6 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:099a66498bf7a40764002793eba66c881a251b76
commit r13-2878-g099a66498bf7a40764002793eba66c881a251b76
Author: Patrick Palka <ppalka@redhat.com>
Date: Mon Sep 26 11:30:17 2022 -0400
c++ modules: variable template partial spec fixes [PR107033]
In r13-2775-g32d8123cd6ce87 I missed that we need to adjust the call to
add_mergeable_specialization in the MK_partial case to correctly handle
variable template partial specializations (it currently assumes we're
always dealing with one for a class template). This fixes an ICE when
converting the testcase from that commit to use an importable header
instead of a named module.
PR c++/107033
gcc/cp/ChangeLog:
* module.cc (trees_in::decl_value): In the MK_partial case for
a variable template partial specialization, pass decl_p=true to
add_mergeable_specialization, and set spec to the VAR_DECL not
the TEMPLATE_DECL.
* pt.cc (add_mergeable_specialization): For a variable template
partial specialization, set the TREE_TYPE of the new
DECL_TEMPLATE_SPECIALIZATIONS node to the TREE_TYPE of the
VAR_DECL not the VAR_DECL itself.
gcc/testsuite/ChangeLog:
* g++.dg/modules/partial-2.cc, g++.dg/modules/partial-2.h: New
files, factored out from ...
* g++.dg/modules/partial-2_a.C, g++.dg/modules/partial-2_b.C: ...
these.
* g++.dg/modules/partial-2_c.H: New test.
* g++.dg/modules/partial-2_d.C: New test.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/107033] [13 Regression] [modules] Variable template of type trait via importable header gives wrong result
2022-09-25 14:08 [Bug c++/107033] New: [13 Regression] [modules] ICE converting to span johelegp at gmail dot com
` (6 preceding siblings ...)
2022-09-26 15:31 ` cvs-commit at gcc dot gnu.org
@ 2022-09-29 21:07 ` ppalka at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-09-29 21:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107033
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #7 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed
^ permalink raw reply [flat|nested] 9+ messages in thread