[Bug c++/103118] [modules] ICE tree check in get_merge_kind at cp/module.cc

2021-11-16 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103118

--- Comment #4 from Johel Ernesto Guerrero Peña  ---
With the setup in Comment 3, now I can also include `` in the GMF of a
module. I don't think this worked last week. Though all I'm doing in the module
is specializing a my-library type trait on some chrono date types.

[Bug c++/103339] New: [modules] ICE in exporting module on use of outside specialization

2021-11-19 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103339

Bug ID: 103339
   Summary: [modules] ICE in exporting module on use of outside
specialization
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/onW6h5vej.

mod.cpp:
```C++
export module mod;
export template struct trait { };
export template concept C = true;
template concept has_trait = C>;
```

test.cpp:
```C++
import mod;
template struct trait { };
```

Output:
```
test.cpp:2:31: internal compiler error: in import_entity_index, at
cp/module.cc:3953
2 | template struct trait { };
  |   ^
0x206aac9 internal_error(char const*, ...)
???:0
0x7d92db fancy_abort(char const*, int, char const*)
???:0
0x966072 module_may_redeclare(tree_node*)
???:0
0xaab517 begin_class_definition(tree_node*)
???:0
0xa0b065 c_parse_file()
???:0
0xb931d2 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.
```

Workaround:
```diff
-template concept has_trait = C>;
+template concept has_trait = C>>;
```

As per the logic in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99631#c1, this
isn't marked with any of the ice-* keywords.

[Bug c++/103341] New: ICE type of variable instantiation constrained on template parameter

2021-11-20 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103341

Bug ID: 103341
   Summary: ICE type of variable instantiation constrained on
template parameter
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/68GYeKqK4.

```C++
template struct is_same { };
template concept same_as = is_same::value;
template inline constexpr same_as auto trait_v{1};
using _ [[maybe_unused]] = decltype(trait_v);
```

Output:
```
: In instantiation of 'constexpr const auto [requires
::same_as<, T>] trait_v':
:4:37:   required from here
:3:52: internal compiler error: tree check: accessed elt 1 of
'tree_vec' with 0 elts in hash, at cp/constraint.cc:2503
3 | template inline constexpr same_as auto trait_v{1};
  |^~~
0x206d4e9 internal_error(char const*, ...)
???:0
0x6da40c tree_vec_elt_check_failed(int, int, char const*, int, char const*)
???:0
0x85fca0 sat_hasher::hash(sat_entry*)
???:0
0x85aed7 satisfaction_cache::satisfaction_cache(tree_node*, tree_node*,
sat_info)
???:0
0x85f01a constraints_satisfied_p(tree_node*, tree_node*)
???:0
0xa3384b do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int)
???:0
0x8d2c1d cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
???:0
0xa46987 instantiate_decl(tree_node*, bool, bool)
???:0
0x8e7c9e maybe_instantiate_decl(tree_node*)
???:0
0x8e9760 mark_used(tree_node*, int)
???:0
0xabe557 finish_id_expression(tree_node*, tree_node*, tree_node*, cp_id_kind*,
bool, bool, bool*, bool, bool, bool, bool, char const**, unsigned int)
???:0
0xa0cc65 c_parse_file()
???:0
0xb94bf2 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1
```

[Bug c++/103339] [modules] ICE in exporting module on use of outside specialization

2021-11-23 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103339

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
In non-reduced code, I got the error from Bug 99861 which I solved with the
workaround above:

```
hash table checking failed: equal operator returns true for a pair of values
with a different hash value
In module waarudo.numbers, imported at
/home/johel/Documents/C++/Repos/waarudo/tests/test.waarudo.numbers.cpp:4:
/home/johel/Documents/C++/Repos/waarudo/sources/waarudo.numbers.cpp: In
substitution of ‘template using number_difference_t = typename
waarudo::number_difference@waarudo.numbers::type [with T = short unsigned
int]’:
/home/johel/Documents/C++/Repos/waarudo/sources/waarudo.numbers.cpp:57:24:  
required by substitution of ‘template  requires  scalar_quantity
using x_component =
waarudo::component@waarudo.geometries [with Q
= waarudo::pixels@waarudo.quantities]’
/home/johel/Documents/C++/Repos/waarudo/tests/test.waarudo.numbers.cpp:111:9:  
required from ‘{anonymous}::test():: [with I = short unsigned int]’
/usr/include/boost/mp11/algorithm.hpp:1039:29:   required from ‘constexpr F
boost::mp11::detail::mp_for_each_impl(boost::mp11::mp_list, F&&) [with T
= {unsigned char, short unsigned int}; F =
{anonymous}::test()::]’
/usr/include/boost/mp11/algorithm.hpp:1072:36:   required from ‘constexpr F
boost::mp11::mp_for_each(F&&) [with L = boost::mp11::mp_list; F = {anonymous}::test()::]’
/home/johel/Documents/C++/Repos/waarudo/tests/test.waarudo.numbers.cpp:110:58: 
 required from here
/home/johel/Documents/C++/Repos/waarudo/sources/waarudo.numbers.cpp:25:32:
internal compiler error: in hashtab_chk_error, at hash-table.c:137
   25 | export template using number_difference_t = typename
number_difference::type;
  |^~~
0x20f297d internal_error(char const*, ...)
???:0
0x97de46 fancy_abort(char const*, int, char const*)
???:0
0x97dc52 hashtab_chk_error()
???:0
0x9eb38e hash_table::verify(tree_node* const&,
unsigned int)
???:0
0x9ea2c8 constraints_satisfied_p(tree_node*, tree_node*)
???:0
0xb8a0ec most_specialized_partial_spec(tree_node*, int)
???:0
0xba6a27 instantiate_class_template(tree_node*)
???:0
0xbf7c74 complete_type_or_maybe_complain(tree_node*, tree_node*, int)
???:0
0xb8d16a tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0xb8be48 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x9ea286 tsubst_requires_expr(tree_node*, tree_node*, int, tree_node*)
???:0
0x9ea2c8 constraints_satisfied_p(tree_node*, tree_node*)
???:0
0xb8bfba tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0xb8e487 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
???:0
0xb8e8df tsubst_argument_pack(tree_node*, tree_node*, int, tree_node*)
???:0
0xb8e664 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
???:0
0xb8e487 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
???:0
0xb8e8df tsubst_argument_pack(tree_node*, tree_node*, int, tree_node*)
???:0
0xb8e664 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
???:0
0xb8e487 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.
```

Workaround:
```C++
template using workaround_gcc_bug_103339 = std::type_identity_t;

export template using number_representation_t =
  typename number_representation>::type;
```

[Bug c++/103339] [modules] ICE in exporting module on use of outside specialization

2021-11-23 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103339

--- Comment #2 from Johel Ernesto Guerrero Peña  ---
Or not really. Removing a comment breaks it again, so I guess the compiler is
already in a bugged state that seems to work fine.

[Bug c++/103339] [modules] ICE in exporting module on use of outside specialization

2021-11-23 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103339

--- Comment #3 from Johel Ernesto Guerrero Peña  ---
Turns out that the error from Bug 99861 just happens occasionally when
compiling.

[Bug c++/100687] [modules, concepts] imported concept gives different result

2021-11-24 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100687

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

 CC||johelegp at gmail dot com

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
I happened upon the same bug when changing a trait to be specialized directly
through the variable template rather than a class template. In my case, I
asserted through the variable template, so I can confirm that it's solely a bug
with modules and not with concepts.

See https://godbolt.org/z/jPT9T6ovP.

mod.cpp:
```C++
export module mod;

export
template< class T >
inline constexpr bool probe = false;
//
template< class R, class C >
inline constexpr bool probe = true;

struct S { int f( ); };
using mf_t = decltype( &S::f );

static_assert( probe< mf_t > );
```

test.cpp:
```C++
import mod;

struct S { int f( ); };
using mf_t = decltype( &S::f );

static_assert( probe< mf_t > );
```

Output:
```
test.cpp:6:16: error: static assertion failed
6 | static_assert( probe< mf_t > );
  |^
```

[Bug c++/103468] New: [modules] ICE Segmentation fault during GIMPLE pass walloca

2021-11-29 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103468

Bug ID: 103468
   Summary: [modules] ICE Segmentation fault during GIMPLE pass
walloca
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: ice-on-valid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

my.std.headers.hpp:
```c++
#include 
#include 
```

my.std.cpp:
```C++
export module my.std;

export import "my.std.headers.hpp";
```

test.cpp:
```C++
import my.std;

int main() {
  std::byte *b{};
  std::copy(b, b, b);
}
```

Compile commands:
```
g++ -pedantic -Wall -Wextra -Wconversion -g -fmodules-ts -std=c++23 -x
c++-header -c my.std.headers.hpp
g++ -pedantic -Wall -Wextra -Wconversion -g -fmodules-ts -std=c++23 -c
my.std.cpp
g++ -pedantic -Wall -Wextra -Wconversion -g -fmodules-ts -std=c++23 -c test.cpp
```

Output:
```
during GIMPLE pass: walloca
In file included from /home/johel/root/gcc/include/c++/12.0.0/algorithm:60,
 from my.std.headers.hpp:1,
of module ./my.std.headers.hpp, imported at my.std.cpp:3,
of module my.std, imported at test.cpp:1:
/home/johel/root/gcc/include/c++/12.0.0/bits/stl_algobase.h: In static member
function ‘static constexpr _OI std::__copy_move::__copy_m(_II, _II, _OI) [with _II =
std::byte*; _OI = std::byte*]’:
/home/johel/root/gcc/include/c++/12.0.0/bits/stl_algobase.h:380:9: internal
compiler error: Segmentation fault
  380 | __copy_m(_II __first, _II __last, _OI __result)
  | ^~~~
0x2140f6d internal_error(char const*, ...)
???:0
0xed8190 irange::set_varying(tree_node*)
???:0
0x14f2d91 gimple_range_global(tree_node*)
???:0
0x1f21f7b ranger_cache::get_global_range(irange&, tree_node*) const
???:0
0x1f1ecdb gimple_ranger::export_global_ranges()
???:0
0x1f5de40 pass_walloca::execute(function*)
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c++/99377] [modules] undefined std::string_view::empty() if referenced in inline exported function

2021-11-29 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99377

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

 CC||johelegp at gmail dot com

--- Comment #5 from Johel Ernesto Guerrero Peña  ---
I get the same error in this case in debug mode:
https://godbolt.org/z/zEGTcMhbh.

mod.cpp:
```C++
export module mod;
export inline void f() {}
```

test.cpp:
```C++
import mod;
// using ::f; // Workaround GCC bug 99377.
template  void g() { f(); }
int main() { g(); }
```

Commands:
```
g++ -pedantic -Wall -Wextra -Wconversion -g -fmodules-ts -std=c++23 -c mod.cpp 
g++ -pedantic -Wall -Wextra -Wconversion -g -fmodules-ts -std=c++23 -c test.cpp 
g++ -pedantic -Wall -Wextra -Wconversion -g -fmodules-ts -std=c++23 *.o
```

Output:
```
/usr/bin/ld: test.o: in function `void g()':
/home/johel/tmp/bug/test.cpp:3: undefined reference to `f()'
collect2: error: ld returned 1 exit status
```

[Bug c++/99377] [modules] undefined std::string_view::empty() if referenced in inline exported function

2021-11-29 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99377

--- Comment #6 from Johel Ernesto Guerrero Peña  ---
A workaround for static member functions:
```C++
template [[nodiscard]] consteval I max() { return
std::numeric_limits::max(); }
if (v == std::numeric_limits::max()) break;
if (v == max()) break;
```

[Bug c++/103564] New: type-requirement that names a constructor should fail

2021-12-05 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103564

Bug ID: 103564
   Summary: type-requirement that names a constructor should fail
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: accepts-invalid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/8dr9oG4Y1.

```C++
template concept C =
  requires { typename T::base; };

struct base { };

static_assert(C);
```

Clang rejects with:
```
:6:1: error: static_assert failed
static_assert(C);
^ ~~~
:6:15: note: because 'base' does not satisfy 'C'
static_assert(C);
  ^
:2:26: note: because 'typename T::base' would be invalid: ISO C++
specifies that qualified reference to 'base' is a constructor name rather than
a type in this context, despite preceding 'typename' keyword
  requires { typename T::base; };
 ^
1 error generated.
```

[Bug c++/99377] [modules] undefined std::string_view::empty() if referenced in inline exported function

2021-12-20 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99377

--- Comment #7 from Johel Ernesto Guerrero Peña  ---
if (v == [] consteval { return std::numeric_limits::max() }()) break;
works too.
More generally, you can avoid the linker error if you don't require the symbol
at link time.

[Bug c++/86105] Conversion to ambiguous/inaccessible rvalue base is valid in unevaluated context

2021-08-28 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86105

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
Denoised: https://godbolt.org/z/87fbMG6f5.
```C++
template concept is_static_castable = requires(From &&
(*from)()) { static_cast(from()); };

struct B { };
struct D : B { };
struct D2 : D, B { };
struct D3 : private B { };

void f() {
  D2 d2;
  (void)static_cast(d2);  // error: invalid
  static_assert(not is_static_castable); // says "is valid"
  D3 d3;
  (void)static_cast(d3);  // error: invalid
  static_assert(not is_static_castable); // says "is valid"
}
```
```
:5:8: warning: direct base 'B' inaccessible in 'D2' due to ambiguity
[-Winaccessible-base]
5 | struct D2 : D, B { };
  |^~
: In function 'void f()':
:10:28: error: 'B' is an ambiguous base of 'D2'
   10 |   (void)static_cast(d2);  // error: invalid
  |^
:11:17: error: static assertion failed
   11 |   static_assert(not is_static_castable); // says "is valid"
  | ^~~~
:13:28: error: 'B' is an inaccessible base of 'D3'
   13 |   (void)static_cast(d3);  // error: invalid
  |^
:14:17: error: static assertion failed
   14 |   static_assert(not is_static_castable); // says "is valid"
  | ^~~~
Compiler returned: 1
```

[Bug c++/99507] Can't return static address from immediate function

2021-08-28 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99507

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
  Known to work||10.3.0, 11.1.0
 Resolution|--- |FIXED
  Known to fail||10.2.0

--- Comment #5 from Johel Ernesto Guerrero Peña  ---
Thank you.

[Bug c++/99141] Name of deduced type unchecked in deduction guide

2021-08-28 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99141

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

  Known to fail||11.0, 12.0

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
Simpler: https://godbolt.org/z/EE9an4Whf.
```C++
templatestruct A{A(T){}};
using B=A;
A(int)->B;
A a{0};
```

[Bug c++/95977] No deallocation of temporary in return-statement during constant evaluation

2021-08-28 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95977

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
  Known to work||10.3.0, 11.1.0
  Known to fail||10.2.0
 Resolution|--- |FIXED

--- Comment #3 from Johel Ernesto Guerrero Peña  ---
Fixed somewhere along the line.

[Bug c++/96090] noexcept operator of potentially-throwing defaulted function gives the wrong result

2021-08-28 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96090

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

  Known to fail||10.3.0, 11.2.0, 12.0
   Keywords||rejects-valid
Summary|Inconsistent querying of|noexcept operator of
   |differring exception|potentially-throwing
   |specifications of   |defaulted function gives
   |explicitly defaulted|the wrong result
   |functions   |

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
Now they all give the wrong answer: https://godbolt.org/z/hroWqTExz.

[Bug c++/95797] Can std::allocator.deallocate newed pointer during constant evaluation

2021-08-28 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95797

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

 Resolution|--- |FIXED
  Known to work||11.0
  Known to fail||10.3.0
 Status|NEW |RESOLVED

--- Comment #2 from Johel Ernesto Guerrero Peña  ---
Fixed somewhere along the line.

[Bug c++/102137] New: class template argument deduction with template template parameter allows explicit deduction guide

2021-08-30 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102137

Bug ID: 102137
   Summary: class template argument deduction with template
template parameter allows explicit deduction guide
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: accepts-invalid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/qc4e95TEK.
```C++
template struct B { B(int){} };  explicit B(int) -> B;
template class T> void f() { [[maybe_unused]] T _ = 0; }
void g() { f(); }
```

[Bug c++/102174] New: Unused result of undefined behavior arithmetic is accepted during constant evaluation

2021-09-02 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102174

Bug ID: 102174
   Summary: Unused result of undefined behavior arithmetic is
accepted during constant evaluation
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: accepts-invalid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/d38ozc91x.
```C++
#include 
constexpr bool f() {
  1 / 0;
  1.0 / 0;
  1 % 0;
  INT32_MIN / INT32_C(-1);
  INT32_MIN * INT32_C(-1);
  INT32_MAX + INT32_C(1);
  INT16_C(INT32_MAX + INT32_C(1));
  return true;
}
constexpr bool b{f()};
```
```
: In function 'constexpr bool f()':
:3:5: warning: division by zero [-Wdiv-by-zero]
3 |   1 / 0;
  |   ~~^~~
:3:5: warning: statement has no effect [-Wunused-value]
:4:7: warning: division by zero [-Wdiv-by-zero]
4 |   1.0 / 0;
  |   ^~~
:4:7: warning: statement has no effect [-Wunused-value]
:5:5: warning: division by zero [-Wdiv-by-zero]
5 |   1 % 0;
  |   ~~^~~
:5:5: warning: statement has no effect [-Wunused-value]
:6:13: warning: integer overflow in expression of type 'int' results in
'-2147483648' [-Woverflow]
6 |   INT32_MIN / INT32_C(-1);
  | ^
:6:13: warning: statement has no effect [-Wunused-value]
:7:13: warning: integer overflow in expression of type 'int' results in
'-2147483648' [-Woverflow]
7 |   INT32_MIN * INT32_C(-1);
  | ^
:7:13: warning: statement has no effect [-Wunused-value]
:8:13: warning: integer overflow in expression of type 'int' results in
'-2147483648' [-Woverflow]
8 |   INT32_MAX + INT32_C(1);
  | ^
:8:13: warning: statement has no effect [-Wunused-value]
In file included from
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-gnu/11.2.0/include/stdint.h:9,
 from
/opt/compiler-explorer/gcc-11.2.0/include/c++/11.2.0/cstdint:41,
 from :1:
:9:21: warning: integer overflow in expression of type 'int' results in
'-2147483648' [-Woverflow]
9 |   INT16_C(INT32_MAX + INT32_C(1));
  | ^
:9:21: warning: statement has no effect [-Wunused-value]
Compiler returned: 0
```

[Bug c++/102191] New: Can't return prvalue with potentially-throwing destructor during constant evaluation

2021-09-03 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102191

Bug ID: 102191
   Summary: Can't return prvalue with potentially-throwing
destructor during constant evaluation
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/8evPWv7cb.
```C++
struct X {
  struct A {
constexpr ~A() noexcept(false) { }
  };

  constexpr A operator()(auto...) { return {}; }
};

void f() { []() consteval { X{}(); }(); }
```
```
: In function 'void f()':
:9:37:   in 'constexpr' expansion of 'f()::().f()::()'
:9:37:   in 'constexpr' expansion of 'X::operator()(auto:1 ...) [with
auto:1 = {}]()'
:9:37: error: modification of '' is not a constant
expression
9 | void f() { []() consteval { X{}(); }(); }
  |~^~
Compiler returned: 1
```

[Bug c++/102220] New: Conversion from cv void* to object-type* not rejected during constant evaluation

2021-09-06 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102220

Bug ID: 102220
   Summary: Conversion from cv void* to object-type* not rejected
during constant evaluation
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: accepts-invalid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/ecYjGsWo7.
```C++
#include 
int main() {
  [i=0]() consteval /*mutable*/ {
++*(int*)(void*)&i;
assert(i == 1);
  }();
}
```

A minimal reproduction:
```C++
int main() {
  [i=0]() consteval {
(void)+*(const int*)(const void*)&i;
  }();
}
```

Discovered at
https://cpplang.slack.com/archives/C263VAF2B/p1630942490163700?thread_ts=1630937296.159200&cid=C263VAF2B.

[Bug c++/102249] New: Can't compare pointer to functions during constant evaluation

2021-09-08 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102249

Bug ID: 102249
   Summary: Can't compare pointer to functions during constant
evaluation
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

This is specified at https://eel.is/c++draft/expr.eq#3. See
https://godbolt.org/z/Wdradsb4a.
```C++
#include 
static_assert(not std::ranges::equal_to{}([]{}, +[]{}));
static_assert(std::not_equal_to{}([]{}, +[]{}));
static_assert([]{} != +[]{});
```
```
:2:15: error: non-constant condition for static assertion
2 | static_assert(not std::ranges::equal_to{}(+[]{}, +[]{}));
  |   ^
In file included from
/opt/compiler-explorer/gcc-11.2.0/include/c++/11.2.0/bits/iterator_concepts.h:37,
 from
/opt/compiler-explorer/gcc-11.2.0/include/c++/11.2.0/bits/stl_iterator_base_types.h:71,
 from
/opt/compiler-explorer/gcc-11.2.0/include/c++/11.2.0/bits/stl_algobase.h:65,
 from
/opt/compiler-explorer/gcc-11.2.0/include/c++/11.2.0/array:40,
 from
/opt/compiler-explorer/gcc-11.2.0/include/c++/11.2.0/tuple:39,
 from
/opt/compiler-explorer/gcc-11.2.0/include/c++/11.2.0/functional:54,
 from :1:
/opt/compiler-explorer/gcc-11.2.0/include/c++/11.2.0/bits/ranges_cmp.h:93:39:
error: '(::_FUN == ::_FUN)' is not a constant expression
   93 |   { return std::forward<_Tp>(__t) == std::forward<_Up>(__u); }
  |~~~^
:3:34: error: non-constant condition for static assertion
3 | static_assert(std::not_equal_to{}(+[]{}, +[]{}));
  |   ~~~^~
In file included from
/opt/compiler-explorer/gcc-11.2.0/include/c++/11.2.0/functional:49,
 from :1:
/opt/compiler-explorer/gcc-11.2.0/include/c++/11.2.0/bits/stl_function.h:509:41:
error: '(::_FUN != ::_FUN)' is not a constant expression
  509 | { return std::forward<_Tp>(__t) != std::forward<_Up>(__u); }
  |  ~~~^
:4:21: error: non-constant condition for static assertion
4 | static_assert(+[]{} != +[]{});
:4:21: error: '(::_FUN != ::_FUN)' is not a
constant expression
Compiler returned: 1
```

[Bug c++/102258] New: dynamic_cast to derived type fails during constant evaluation

2021-09-09 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102258

Bug ID: 102258
   Summary: dynamic_cast to derived type fails during constant
evaluation
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/dsEzaxW47.
```C++
struct B { virtual ~B() = default; };
struct D : B { constexpr ~D() override { } };
int main() {
  []() consteval {
B* b = new D;
dynamic_cast(*b);
delete b;
  }();
}
```
```
: In function 'int main()':
:8:4:   in 'constexpr' expansion of 'main()::().main()::()'
:6:5: error: reference 'dynamic_cast' failed
6 | dynamic_cast(*b);
  | ^~~~
:6:5: note: dynamic type 'D [1]' of its operand does not have a base
class of type 'D'
Compiler returned: 1
```

[Bug c++/102258] dynamic_cast to derived type fails during constant evaluation

2021-09-09 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102258

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
Workaround for my use-case: https://godbolt.org/z/5Woe8dvan.
```C++
#include 
#include 
#include 
#include 
#include 
struct B { virtual ~B() = default; };
struct D : B { int x{1}; constexpr ~D() override { } };

template
  requires(
std::is_pointer_v and
not std::is_same_v>,
std::remove_cv_t> and
std::derived_from, Base>)
[[nodiscard]] constexpr auto dynamic_downcast(Base* b)
  -> decltype(&dynamic_cast&>(*b)) {
  if (b == nullptr) return nullptr;
  if (&typeid(*b) == &typeid(std::remove_pointer_t&))
return &static_cast&>(*b);
  throw std::bad_cast{};
}

int main() {
  []() consteval {
B* b = new D;
assert(dynamic_downcast(b)->x == 1);
delete b;
  }();
}
```

[Bug c++/102258] dynamic_cast to derived type fails during constant evaluation

2021-09-09 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102258

--- Comment #2 from Johel Ernesto Guerrero Peña  ---
That still doesn't work because you can't compare (the addresses of) different
`std::type_info` objects.

[Bug c++/102267] New: Can't compare pointers to instantiated variables during constant evaluation

2021-09-09 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102267

Bug ID: 102267
   Summary: Can't compare pointers to instantiated variables
during constant evaluation
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

This is specified at https://eel.is/c++draft/expr.eq#3. See
https://godbolt.org/z/n995WdYff.
```C++
template constexpr char v{};
template<> constexpr char v<2>{};
template<> constexpr char v<3>{};
static_assert(&v<0> != &v<1>);
static_assert(&v<2> != &v<3>);
```
```
:4:21: error: non-constant condition for static assertion
4 | static_assert(&v<0> != &v<1>);
  |   ~~^~~~
:4:21: error: '((& v<0>) != (& v<1>))' is not a constant expression
Compiler returned: 1
```

[Bug c++/102267] Can't compare pointers to non-specialization instantiated variables during constant evaluation

2021-09-09 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102267

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

Summary|Can't compare pointers to   |Can't compare pointers to
   |instantiated variables  |non-specialization
   |during constant evaluation  |instantiated variables
   ||during constant evaluation
 Status|RESOLVED|UNCONFIRMED
 Resolution|DUPLICATE   |---

--- Comment #2 from Johel Ernesto Guerrero Peña  ---
More generally: https://godbolt.org/z/63qoWc1zv.
```C++
template struct x { static constexpr char v{}; };
template<> struct x<2> { static constexpr char v{}; };
template<> struct x<3> { static constexpr char v{}; };
static_assert(&x<0>::v != &x<1>::v);
static_assert(&x<2>::v != &x<3>::v);
```
```
:4:24: error: non-constant condition for static assertion
4 | static_assert(&x<0>::v != &x<1>::v);
  |   ~^~~
:4:24: error: '((& x<0>::v) != (& x<1>::v))' is not a constant
expression
Compiler returned: 1
```

[Bug c++/102284] New: Can access object outside of its lifetime during constant evaluation

2021-09-10 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102284

Bug ID: 102284
   Summary: Can access object outside of its lifetime during
constant evaluation
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: accepts-invalid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

This is prohibited at https://eel.is/c++draft/basic.life#7.1.
See https://godbolt.org/z/exKnnT935.
```C++
#include 
struct X { int x; };
int main() {
  []() consteval {
{
  X x{};
  x.~X();
  ++x.x;
  std::construct_at(&x);
}
{
  union { X x{}; };
  x.~X();
  ++x.x;
}
  }();
}
```

[Bug c++/102284] Can access object outside of its lifetime during constant evaluation

2021-09-10 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102284

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
There's also https://eel.is/c++draft/basic.life#9.sentence-1 to consider.
See https://godbolt.org/z/P97Kaqhv8.
```C++
struct X { int x; };
int main() {
  []() consteval {
X x{};
x.~X();
  }();
}
```

[Bug c++/102284] Can access object outside of its lifetime during constant evaluation

2021-09-10 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102284

--- Comment #2 from Johel Ernesto Guerrero Peña  ---
Fixed that: https://godbolt.org/z/YGf4GTP5P.
```C++
struct X { constexpr ~X() { } };
int main() {
  []() consteval {
X x{};
x.~X();
  }();
}
```

[Bug c++/102267] Can't compare pointers to non-specialization instantiated variables during constant evaluation

2021-09-10 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102267

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #4 from Johel Ernesto Guerrero Peña  ---
I don't think this is a duplicate of Bug 69681. They may be the same underlying
issue, but manifest differently. In case they weren't, could closing this as a
duplicate cause the other report to be fixed but not this? It'd be good to
generalize the duplicate's summary. That would help with reducing duplicate
reports thanks to the "Possible Duplicates" feature when submitting a new one.

*** This bug has been marked as a duplicate of bug 94716 ***

[Bug c++/94716] comparison of address of template variables should be constexpr

2021-09-10 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94716

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

 CC||johelegp at gmail dot com

--- Comment #3 from Johel Ernesto Guerrero Peña  ---
*** Bug 102267 has been marked as a duplicate of this bug. ***

[Bug c++/102284] Can access object outside of its lifetime during constant evaluation

2021-09-10 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102284

--- Comment #4 from Johel Ernesto Guerrero Peña  ---
If there is, I confirmed it's not in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55004.

[Bug c++/82877] negative array index accepted in a pointer difference expression in constexpr context

2021-09-12 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82877

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

 CC||johelegp at gmail dot com

--- Comment #4 from Johel Ernesto Guerrero Peña  ---
Up to GCC 10. Not since GCC 11.

Another example: https://godbolt.org/z/GW3rrejjq.
```C++
constexpr void f(int i) {
  (&i)[-1];
}
int main() {
  []() consteval {
f(0);
  }();
}
```

Bug 89149 may be a duplicate of this.

[Bug c++/102420] New: null pointer dereference constant

2021-09-20 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102420

Bug ID: 102420
   Summary: null pointer dereference constant
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: accepts-invalid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

[Bug c++/102420] null pointer dereference during constant evaluation not rejected

2021-09-20 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102420

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

Summary|null pointer dereference|null pointer dereference
   |constant|during constant evaluation
   ||not rejected
 Blocks||55004

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
See https://godbolt.org/z/r5zxPTcK6.
```C++
struct X {
  constexpr void f() { }
};
int main() {
  []() consteval {
X* x{nullptr};
x->f();
  }();
}
```


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55004
[Bug 55004] [meta-bug] constexpr issues

[Bug c++/100583] [modules] ICE when importing

2021-09-26 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100583

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
Please, add Bug 99227 to **Blocks:** for visibility.

[Bug c++/99227] [meta] [modules] Bugs relating to header-units of STL header files

2021-09-28 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99227

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

 CC||johelegp at gmail dot com

--- Comment #4 from Johel Ernesto Guerrero Peña  ---
Also depends on Bug 100583.

[Bug c++/102524] New: [modules] Missing diagnostic when an exported namespace is empty

2021-09-28 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102524

Bug ID: 102524
   Summary: [modules] Missing diagnostic when an exported
namespace is empty
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: diagnostic
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

This is specified at [module.interface].3:
> An exported declaration that is not a module-import-declaration
> shall declare at least one name.

GCC doesn't print any diagnostic (https://godbolt.org/z/oEbTjcfeo)
whereas Clang gives a warning (https://godbolt.org/z/ajszM74j9):
> `mod.cpp:2:18: warning: ISO C++20 does not permit a declaration that
> does not introduce any names to be exported [-Wexport-unnamed]`

[Bug c++/102536] New: [modules] ICE Error reporting routines re-entered

2021-09-29 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102536

Bug ID: 102536
   Summary: [modules] ICE Error reporting routines re-entered
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: ice-on-valid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/ehPzxqzWK.

mod.cpp:
```C++
export module mod;

namespace mod {

export struct X {
  X() { }

  constexpr void f() {
[](auto) { }(0);
  }
};

}
```

test.cpp:
```C++
import mod;

int main() {
  mod::X{}.f();
}
```

```
Internal compiler error: Error reporting routines re-entered.
0x1fe6b9d error_at(unsigned int, char const*, ...)
???:0
0x989719 lazy_load_pendings(tree_node*)
???:0
0x994388 get_class_binding(tree_node*, tree_node*, bool)
???:0
0xa953ce dfs_walk_all(tree_node*, tree_node* (*)(tree_node*, void*), tree_node*
(*)(tree_node*, void*), void*)
???:0
0xa9558c lookup_member(tree_node*, tree_node*, int, bool, int,
access_failure_info*)
???:0
0x91b9aa lambda_function(tree_node*)
???:0
0x2003411 pp_format(pretty_printer*, text_info*)
???:0
0x2003a90 pp_format_verbatim(pretty_printer*, text_info*)
???:0
0x2003b71 pp_verbatim(pretty_printer*, char const*, ...)
???:0
0x1fe5b51 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
???:0
0x1fe6b9d error_at(unsigned int, char const*, ...)
???:0
0x989719 lazy_load_pendings(tree_node*)
???:0
0x994388 get_class_binding(tree_node*, tree_node*, bool)
???:0
0xa953ce dfs_walk_all(tree_node*, tree_node* (*)(tree_node*, void*), tree_node*
(*)(tree_node*, void*), void*)
???:0
0xa9558c lookup_member(tree_node*, tree_node*, int, bool, int,
access_failure_info*)
???:0
0x91b9aa lambda_function(tree_node*)
???:0
0x93419b mangle_decl(tree_node*)
???:0
0x14c5f02 decl_assembler_name(tree_node*)
???:0
0xc70f8a cgraph_node::finalize_function(tree_node*, bool)
???:0
0x9873f8 module_state::read_cluster(unsigned int)
???:0
```

[Bug c++/102576] New: [modules] Importing doesn't permit implicit uses

2021-10-03 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102576

Bug ID: 102576
   Summary: [modules] Importing  doesn't permit
implicit uses
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

A use like

```C++
import;

constexpr void test() {
  for (const int i : {0, 1, -1}) { }
}
```

results in an error like

```
error: deducing from brace-enclosed initializer list requires ‘#include
’
3 | import;
  +++ |+#include 
4 | // import;
..
   11 |   for (const int i : {0, 1, -1}) {
  |   ^
```

[Bug c++/102576] [modules] Importing doesn't permit implicit uses

2021-10-03 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102576

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
`` is specified as including ``.
It doesn't with with that either:

```C++
import;

namespace {

constexpr void test() {
  for (const int i : {0, 1, -1}) { }
```

```
error: deducing from brace-enclosed initializer list requires ‘#include
’
2 | import;
  +++ |+#include 
3 | // import;
..
   10 |   for (const int i : {0, 1, -1}) {
  |   ^
```

This might apply more generally to standard headers specified as including
other headers.

[Bug c++/100583] [modules] ICE when importing

2021-10-03 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100583

--- Comment #3 from Johel Ernesto Guerrero Peña  ---
Thank you.

> The solution is to use the include and remove the gcm file altogether.

Is this still the case? I still get an ICE.

[Bug c++/102598] New: [modules] ICE in pp_string, at pretty-print.c

2021-10-04 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102598

Bug ID: 102598
   Summary: [modules] ICE in pp_string, at pretty-print.c
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: ice-on-valid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/3rGTTr6jE.

write.cpp:
```C++
export module write;
export void write(const auto &v) {}
```

main.cpp:
```C++
import write;
int main() { write(char{}); }
```

Compile commands:
```
gcc -Wall -Wextra -fmodules-ts -std=c++23 -c write.cpp
gcc -Wall -Wextra -fmodules-ts -std=c++23 -c main.cpp
```

Output:
```
In module write, imported at main.cpp:1:
in pp_string, at pretty-print.c:1827
0x2068f9d internal_error(char const*, ...)
???:0
0x973872 fancy_abort(char const*, int, char const*)
???:0
0x2086861 pp_format(pretty_printer*, text_info*)
???:0
0x2087d92 pp_verbatim(pretty_printer*, char const*, ...)
???:0
0x2067adf diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
???:0
0x2068720 warning_at(unsigned int, int, char const*, ...)
???:0
0xca067c do_warn_unused_parameter(tree_node*)
???:0
0xa3ba82 finish_function(bool)
???:0
0xb77dfb instantiate_decl(tree_node*, bool, bool)
???:0
0xb9b883 instantiate_pending_templates(int)
???:0
0xa50e3c c_parse_final_cleanups()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c++/102598] [modules] ICE in pp_string, at pretty-print.c

2021-10-04 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102598

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
Attempts to reduce another wrong-code bug lead to this.

[Bug c++/102600] New: [modules] ICE Segmentation fault during GIMPLE pass evrp

2021-10-04 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102600

Bug ID: 102600
   Summary: [modules] ICE Segmentation fault during GIMPLE pass
evrp
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: ice-on-valid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

main.cpp:
```C++
import;
void push(std::byte) {}
void write(char v) { push(static_cast(v)); }
int main() { write(char{}); }
```

Compile commands:
```
gcc -std=c++23 -O3 -fmodules-ts -x c++-system-header -c cstddef
gcc -std=c++23 -O3 -fmodules-ts -c main.cpp
```

Output:
```
during GIMPLE pass: evrp
main.cpp: In function ‘void write(char)’:
main.cpp:4:29: internal compiler error: Segmentation fault
4 | int main() { write(char{}); }
  | ^
0x2068f9d internal_error(char const*, ...)
???:0
0xca4c68 wi::to_wide(tree_node const*)
???:0
0x1f85553 operator_cast::inside_domain_p(generic_wide_int
const&, generic_wide_int const&, irange const&) const
???:0
0x1f8c51d operator_cast::fold_pair(irange&, unsigned int, irange const&, irange
const&) const
???:0
0x1f8cb6a operator_cast::fold_range(irange&, tree_node*, irange const&, irange
const&, tree_code) const
???:0
0x1e723b0 fold_using_range::range_of_range_op(irange&, gimple*, fur_source&)
???:0
0x1e73142 fold_using_range::fold_stmt(irange&, gimple*, fur_source&,
tree_node*)
???:0
0x1e67484 gimple_ranger::range_of_stmt(irange&, gimple*, tree_node*)
???:0
0x1e681ff gimple_ranger::range_of_expr(irange&, tree_node*, gimple*)
???:0
0x14ec2f1 range_query::value_of_expr(tree_node*, gimple*)
???:0
0x1e7bda8 rvrp_folder::value_of_expr(tree_node*, gimple*)
???:0
0x138eebe substitute_and_fold_dom_walker::before_dom_children(basic_block_def*)
???:0
0x1e37697 dom_walker::walk(basic_block_def*)
???:0
0x138e03d substitute_and_fold_engine::substitute_and_fold(basic_block_def*)
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c++/102607] New: [modules] option -g results in undefined reference to `typeinfo for type`

2021-10-05 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102607

Bug ID: 102607
   Summary: [modules] option -g results in undefined reference to
`typeinfo for type`
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: link-failure
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/qP6EPWhEz.

mod.cpp:
```C++
export module mod;
export struct B {
  virtual ~B() = default;
};
```

main.cpp:
```C++
import mod;
int main() {
  struct D : B {};
  (void)D{};
}
```

Commands:
```
g++ -std=c++23 -fmodules-ts -g -c mod.cpp
g++ -std=c++23 -fmodules-ts -g -c main.cpp
g++ mod.o main.o
```

Output:
```
/usr/bin/ld: main.o:(.data.rel.ro+0x8): undefined reference to `typeinfo for B'
/usr/bin/ld: main.o:(.data.rel.ro+0x30): undefined reference to `typeinfo for
B'
collect2: error: ld returned 1 exit status
```

[Bug c++/102607] [modules] option -g results in undefined reference to `typeinfo for type`

2021-10-05 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102607

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
A workaround is to define `B`'s destructor as
`constexpr virtual ~B() { }`.

[Bug c++/102600] [modules] ICE Segmentation fault during GIMPLE pass evrp

2021-10-06 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102600

--- Comment #2 from Johel Ernesto Guerrero Peña  ---
A workaround:

```C++
export using byte = // Workaround GCC bug 102600.
#if not defined(NDEBUG) or (defined(__clang__) or not defined(__GNUC__))
  std::byte;
#else
  unsigned char;
#endif
```

[Bug c++/102931] New: ICE explicit lambda call operator without template keyword

2021-10-25 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102931

Bug ID: 102931
   Summary: ICE explicit lambda call operator without template
keyword
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: ice-on-invalid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/8GGoqr9z3.

```C++
template void f() {
  []() {

  }.operator()();
}
int main() {
  f();
}
```

```
: In instantiation of 'void f() [with T = int]':
:7:9:   required from here
:4:17: internal compiler error: in lookup_template_class_1, at
cp/pt.c:10017
2 |   []() {
  |   ~  
3 | 
  |  
4 |   }.operator()();
  |   ~~^
0x1ffe519 internal_error(char const*, ...)
???:0
0x7d6f1b fancy_abort(char const*, int, char const*)
???:0
0xa54df1 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
???:0
0xa4005d tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0xa45fc7 instantiate_decl(tree_node*, bool, bool)
???:0
0xa88b1b instantiate_pending_templates(int)
???:0
0x8edf99 c_parse_final_cleanups()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1
```

[Bug c++/102933] New: Can't use CTAD in template argument

2021-10-25 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102933

Bug ID: 102933
   Summary: Can't use CTAD in template argument
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/P8xq8h9M1.

```C++
template struct X { T t; };
template void f();
template void g() {
  f();
}
int main() {
  g();
}
```

```
: In function 'void g()':
:7:5: error: invalid use of 'X<...auto...>' in template argument
7 |   f();
  | ^
Compiler returned: 1
```

[Bug c++/102963] New: [modules] ICE failed static_assert of concept

2021-10-27 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102963

Bug ID: 102963
   Summary: [modules] ICE failed static_assert of concept
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/7h1MPqe1h.

mod.cpp:
```C++
export module mod;
export template
concept C = false;
```

test.cpp:
```C++
import mod;
static_assert(C);
```

Output:
```
test.cpp:2:15: error: static assertion failed
2 | static_assert(C);
  |   ^~
test.cpp:2:15: note: constraints not satisfied
'
In module mod, imported at /app/test.cpp:1:
mod.cpp:3:9:   in import_entity_index, at cp/module.cc:3953
3 | concept C = false;
  | ^
0x20037b9 internal_error(char const*, ...)
???:0
0x7d6c17 fancy_abort(char const*, int, char const*)
???:0
0x966d5c get_importing_module(tree_node*, bool)
???:0
0x201fcb1 pp_format(pretty_printer*, text_info*)
???:0
0x2020330 pp_format_verbatim(pretty_printer*, text_info*)
???:0
0x2020411 pp_verbatim(pretty_printer*, char const*, ...)
???:0
0x9046d7 maybe_print_single_constraint_context(diagnostic_context*, tree_node*)
???:0
0x20023f1 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
???:0
0x2002d4d inform(unsigned int, char const*, ...)
???:0
0x86008f diagnose_constraints(unsigned int, tree_node*, tree_node*)
???:0
0xab8483 finish_static_assert(tree_node*, tree_node*, unsigned int, bool, bool)
???:0
0xa0bea5 c_parse_file()
???:0
0xb92e22 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c++/102963] [modules] ICE failed static_assert of concept

2021-10-27 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102963

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
As per the logic in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99631#c1, this
isn't marked with any of the ice-* keywords.

[Bug c++/102975] New: Local alias diagnosed as unused when used in failing constraint

2021-10-27 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102975

Bug ID: 102975
   Summary: Local alias diagnosed as unused when used in failing
constraint
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: diagnostic
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/aePcW8WjK.

```C++
template concept Never = false;
template concept C = Never;
void f() {
  struct X {
using type = int;
  };
  static_assert(not C);
}
```

```
: In function 'void f()':
:5:11: warning: typedef 'using type = int' locally defined but not used
[-Wunused-local-typedefs]
5 | using type = int;
  |   ^~~~
```

[Bug c++/102975] Local alias diagnosed as unused when used in failing constraint

2021-10-31 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102975

--- Comment #4 from Johel Ernesto Guerrero Peña  ---
I'm fine with closing this as RESOLVED INVALID or something along those lines.

[Bug libstdc++/107378] New: `get_if` implementation "is not a constant expression"

2022-10-24 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107378

Bug ID: 107378
   Summary: `get_if` implementation "is not a constant expression"
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/cf1T7q6Tj.

```C++
#include 
static_assert([v = std::variant{}] { return get_if<0>(&v); }());
```

```
:2:67: error: non-constant condition for static assertion
2 | static_assert([v = std::variant{}] { return get_if<0>(&v); }());
  |   ^~
In file included from :1:
:2:67:   in 'constexpr' expansion of '{std::variant{std::__detail::__variant::_Variant_base{std::__detail::__variant::_Move_assign_base{std::__detail::__variant::_Copy_assign_base{std::__detail::__variant::_Move_ctor_base{std::__detail::__variant::_Copy_ctor_base{std::__detail::__variant::_Variant_storage{std::__detail::__variant::_Variadic_union{std::__detail::__variant::_Uninitialized{0}}, 0.()'
:2:60:   in 'constexpr' expansion of 'std::get_if<0, int*>((& v))'
/opt/compiler-explorer/gcc-trunk-20221024/include/c++/13.0.0/variant:1183:11:
error: '((&.::__v) != 0)' is not a constant expression
 1183 |   if (__ptr && __ptr->index() == _Np)
  |   ^
Compiler returned: 1
```

[Bug c++/107378] `get_if` implementation "is not a constant expression"

2022-10-24 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107378

--- Comment #3 from Johel Ernesto Guerrero Peña  ---
MSVC accepts https://godbolt.org/z/nheYz9aez.

```C++
static_assert([i = 0] { return &i != nullptr; }());
```

```
: In lambda function:
:1:35: warning: the address of 'i' will never be NULL [-Waddress]
1 | static_assert([i = 0] { return &i != nullptr; }());
  |~~~^~
:1:21: note: 'i' declared here
1 | static_assert([i = 0] { return &i != nullptr; }());
  | ^
: At global scope:
:1:48: error: non-constant condition for static assertion
1 | static_assert([i = 0] { return &i != nullptr; }());
  |   ~^~
:1:35: error: '((&.::__i) != 0)' is not a constant
expression
1 | static_assert([i = 0] { return &i != nullptr; }());
  |~~~^~
Compiler returned: 1
```

[Bug c++/106363] [13 Regression] [modules] Can't selectively reexport imported declaration in same namespace

2022-10-24 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106363

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

Summary|[modules] Can't selectively |[13 Regression] [modules]
   |reexport imported   |Can't selectively reexport
   |declaration in same |imported declaration in
   |namespace   |same namespace

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
Reexporting is not the problem. The _using-declaration_ is.

Reproducer script:
```bash
#!/bin/bash
CXX=g++
echo "mod2 mod2.gcm
mod mod.gcm" > mm.txt
echo "export module mod2;
namespace ns {
export int x = 0;
}" > mod2.cpp
echo "export module mod;
import mod2;
namespace ns {
export using ns::x;
}" > mod.cpp
$CXX -std=c++23 -fmodules-ts -fmodule-mapper=mm.txt -c mod2.cpp
$CXX -std=c++23 -fmodules-ts -fmodule-mapper=mm.txt -c mod.cpp
```

[Bug c++/106363] [13 Regression] [modules] ICE using-declaration of imported name in the same namespace

2022-10-24 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106363

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

  Known to work||12.2.0
  Known to fail||13.0

--- Comment #2 from Johel Ernesto Guerrero Peña  ---
GCC 12.2 accepts: https://godbolt.org/z/4ExevrnWx.

[Bug c++/107378] `get_if` implementation "is not a constant expression"

2022-10-24 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107378

--- Comment #5 from Johel Ernesto Guerrero Peña  ---
I think so. My actual use case looks like `constexpr auto v = E;` at global
scope, where `E` creates a temporary with a subobject of `std::variant`.
Wrapping `E` in an IILE is a workaround for this Bug.

[Bug c++/107938] New: ICE directly returning `this` of `extern` variable in template

2022-11-30 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107938

Bug ID: 107938
   Summary: ICE directly returning `this` of `extern` variable in
template
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Keywords: ice-on-valid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://compiler-explorer.com/z/4d1esaber.

```C++
struct Q {
  int n;
  constexpr const Q* operator()(auto) const { return this; }
};

extern const Q q;

template
constexpr const Q* p = q(0);
```

```
:9:27: internal compiler error: Segmentation fault
9 | constexpr const Q* p = q(0);
  |   ^
0x22e3a9e internal_error(char const*, ...)
???:0
0xce2006 convert_for_initialization(tree_node*, tree_node*, tree_node*, int,
impl_conv_rhs, tree_node*, int, int)
???:0
0xced3f0 store_init_value(tree_node*, tree_node*, vec**, int)
???:0
0xb22845 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
???:0
0xc20997 c_parse_file()
???:0
0xd5b949 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1
```

Being less direct works: https://compiler-explorer.com/z/jn99aG36e.

[Bug c++/107939] New: Rejects use of `extern const` variable in a template

2022-11-30 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107939

Bug ID: 107939
   Summary: Rejects use of `extern const` variable in a template
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://compiler-explorer.com/z/q3a7e7s1e.
Changing `#if 1` to `#if 0` works, so this can't be due to
> The program is ill-formed, no diagnostic required, if:
> (6.4) a hypothetical instantiation of a template immediately following its 
> definition would be ill-formed due to a construct that does not depend on a 
> template parameter, or
> -- https://eel.is/c++draft/temp.res.general#6.4

And since all compilers accept it as a non-template, nothing in [expr.const] is
being violated.

```C++
struct Q {
  struct P {
const Q* p;
  };
  int n;
  constexpr P operator()(auto) const { return {this}; }
};

extern const Q q;

#if 1
template constexpr auto p = q(0);
static_assert(p<0>.p == &q);
#else
constexpr auto p = q(0);
static_assert(p.p == &q);
#endif

constexpr Q q = {};
```

```
:12:37: error: the value of 'q' is not usable in a constant expression
   12 | template constexpr auto p = q(0);
  | ^
:9:16: note: 'q' was not declared 'constexpr'
9 | extern const Q q;
  |^
:13:22: error: non-constant condition for static assertion
   13 | static_assert(p<0>.p == &q);
  |   ~~~^
Compiler returned: 1
```

[Bug c++/107939] [11/12/13 Regression] Rejects use of `extern const` variable in a template

2022-11-30 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107939

--- Comment #2 from Johel Ernesto Guerrero Peña  ---
Making the expression using the `extern const` variable more complex or
indirect makes it work. With an IILE, for example:
https://compiler-explorer.com/z/EjYYvPvqT.

[Bug c++/108169] class type template parameters are const in GCC (differs from other compilers)

2022-12-26 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108169

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

 CC||johelegp at gmail dot com

--- Comment #8 from Johel Ernesto Guerrero Peña  ---
This seems to be the same as Bug 99631.

[Bug c++/105743] New: Bogus unused but set lambda warning

2022-05-26 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105743

Bug ID: 105743
   Summary: Bogus unused but set lambda warning
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Keywords: diagnostic
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/xq16xac15.

```C++
void f(auto x) { x(0); }
void g() {
  static constexpr auto h = [](...) { };
  f([](auto x) { h(x); });
}
```

```
: In function 'void g()':
:3:25: warning: variable 'h' set but not used
[-Wunused-but-set-variable]
3 |   static constexpr auto h = [](...) { };
  | ^
```

Arguably, `h(x)` could perform ADL on `x`. But perhaps it'd be better to stay
silent, like the other compilers.

[Bug c++/105743] Bogus unused but set lambda warning

2022-05-26 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105743

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
Duplicate of Bug 105571.

*** This bug has been marked as a duplicate of bug 105571 ***

[Bug c++/105571] Spurious "set but not used" on static constexpr local, used in lambda

2022-05-26 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105571

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

 CC||johelegp at gmail dot com

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
*** Bug 105743 has been marked as a duplicate of this bug. ***

[Bug c++/105571] Spurious "set but not used" on static constexpr local, used in lambda

2022-05-26 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105571

--- Comment #2 from Johel Ernesto Guerrero Peña  ---
Simplified reproducer from Bug 105743:

See https://godbolt.org/z/xq16xac15.

```C++
void f(auto x) { x(0); }
void g() {
  static constexpr auto h = [](...) { };
  f([](auto x) { h(x); });
}
```

```
: In function 'void g()':
:3:25: warning: variable 'h' set but not used
[-Wunused-but-set-variable]
3 |   static constexpr auto h = [](...) { };
  | ^
```

Arguably, `h(x)` could perform ADL on `x`. But perhaps it'd be better to stay
silent, like the other compilers.

[Bug c++/105761] New: ICE on hidden friend definition defined in base type

2022-05-28 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105761

Bug ID: 105761
   Summary: ICE on hidden friend definition defined in base type
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Keywords: ice-on-valid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/v8arThEs1.

```C++
#include 

template class X {
  friend auto f(X);
};

template> struct downcast_t { using type = void;
};
template struct downcast_t{}))>> {
using type = decltype(f(X{})); };

template using downcast = typename downcast_t::type;

static_assert(std::is_same_v>);

struct Y : X {
  friend auto f(X) { return 0L; }
};

static_assert(std::is_same_v>);
```

```
:4:18: warning: friend declaration 'auto f(X)' declares a
non-template function [-Wnon-template-friend]
4 |   friend auto f(X);
  |  ^
:4:18: note: (if this is not what you intended, make sure the function
template has already been declared and add '<>' after the function name here)
:15:20: internal compiler error: in push_template_decl, at
cp/pt.cc:6125
   15 |   friend auto f(X) { return 0L; }
  |^
0x21ffa39 internal_error(char const*, ...)
  ???:0
0x7452f3 fancy_abort(char const*, int, char const*)
  ???:0
0x82a0cd start_preparsed_function(tree_node*, tree_node*, int)
  ???:0
0x98cb8d c_parse_file()
  ???:0
0xb21d91 c_common_parse_file()
  ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c++/105761] ICE on hidden friend definition defined in base type

2022-05-28 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105761

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
Simplified: https://godbolt.org/z/66Gd84dos.

```C++
template 
class X {
  friend auto f(X);
};

struct Y : X {
  friend auto f(X) { return 0L; }
};
```

[Bug c++/105044] [modules] ICE in comptypes, at cp/typeck.c:1529

2022-07-03 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105044

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
Another simpler reproducer from another use-case:
https://godbolt.org/z/jroqv6Kzq.

`mod.cpp`:
```C++
export module mod;
export template struct constant { };
export template struct is_constant { };
struct monostate { };
inline constexpr constant c1{};
```

`test.cpp`:
```C++
import mod;
is_constant> v;
int main() { }
```

Output:
```
In module mod, imported at /app/test.cpp:1:
mod.cpp: In instantiation of 'struct is_constant@mod >':
test.cpp:2:26:   required from here
mod.cpp:3:31: internal compiler error: in comptypes, at cp/typeck.cc:1531
3 | export template struct is_constant { };
  |   ^~~
0x2216469 internal_error(char const*, ...)
???:0
0x74b7d9 fancy_abort(char const*, int, char const*)
???:0
0xa90b66 comptypes(tree_node*, tree_node*, int)
???:0
0x833e5d complete_vars(tree_node*)
???:0
0x7ab99b finish_struct_1(tree_node*)
???:0
0xa13ed4 instantiate_class_template(tree_node*)
???:0
0x823818 start_decl_1(tree_node*, bool)
???:0
0x84b6a6 start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
???:0
0x99555d c_parse_file()
???:0
0xb2bc61 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c++/105044] [modules] ICE in comptypes, at cp/typeck.cc:1531

2022-07-03 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105044

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

Summary|[modules] ICE in comptypes, |[modules] ICE in comptypes,
   |at cp/typeck.c:1529 |at cp/typeck.cc:1531

--- Comment #2 from Johel Ernesto Guerrero Peña  ---
Another simpler reproducer from another use-case:
https://godbolt.org/z/jroqv6Kzq.

`mod.cpp`:
```C++
export module mod;
export template struct constant { };
export template struct is_constant { };
struct monostate { };
inline constexpr constant c1{};
```

`test.cpp`:
```C++
import mod;
is_constant> v;
int main() { }
```

Output:
```
In module mod, imported at /app/test.cpp:1:
mod.cpp: In instantiation of 'struct is_constant@mod >':
test.cpp:2:26:   required from here
mod.cpp:3:31: internal compiler error: in comptypes, at cp/typeck.cc:1531
3 | export template struct is_constant { };
  |   ^~~
0x2216469 internal_error(char const*, ...)
???:0
0x74b7d9 fancy_abort(char const*, int, char const*)
???:0
0xa90b66 comptypes(tree_node*, tree_node*, int)
???:0
0x833e5d complete_vars(tree_node*)
???:0
0x7ab99b finish_struct_1(tree_node*)
???:0
0xa13ed4 instantiate_class_template(tree_node*)
???:0
0x823818 start_decl_1(tree_node*, bool)
???:0
0x84b6a6 start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
???:0
0x99555d c_parse_file()
???:0
0xb2bc61 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c++/105044] [modules] ICE in comptypes, at cp/typeck.cc:1531

2022-07-03 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105044

--- Comment #3 from Johel Ernesto Guerrero Peña  ---
Enough recompilations from the actual use-case show this error:
```
/home/johel/Documents/C++/Repos/Waarudo/tests/unit/test.waarudo.quantities.cpp:
In substitution of ‘template struct
waarudo::is_unit@waarudo.quantities*> [with auto ...D = {waarudo::ratio@waarudo.quantities{146097, 400}, (&
waarudo::day@waarudo.quantities)}]’:
/home/johel/Documents/C++/Repos/Waarudo/tests/unit/test.waarudo.quantities.cpp:21:57:
  required from here
/home/johel/Documents/C++/Repos/Waarudo/tests/unit/test.waarudo.quantities.cpp:21:57:
internal compiler error: tree check: expected tree that contains ‘typed’
structure, have ‘ggc_freed’ in convert_nontype_argument, at cp/pt.cc:7763
   21 | static_assert(waarudo::is_unit::value);
  | ^~
0x226d11c internal_error(char const*, ...)
???:0
0x8d094f tree_contains_struct_check_failed(tree_node const*,
tree_node_structure_enum, char const*, int, char const*)
???:0
0xbc4daa lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
???:0
0xbafdb7 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0xbbf9eb tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
???:0
0xbae4e6 most_specialized_partial_spec(tree_node*, int)
???:0
0xbd7a1c instantiate_class_template(tree_node*)
???:0
0xc2fe01 complete_type(tree_node*)
???:0
0xb7a0db c_parse_file()
???:0
0xcb9cd1 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c++/106287] New: Implicit virtual destructor needs to be explicitly defaulted for constant evaluation

2022-07-13 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106287

Bug ID: 106287
   Summary: Implicit virtual destructor needs to be explicitly
defaulted for constant evaluation
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/4WaevWoEs.

```C++
template struct A : T {
  constexpr A(T v) : T{v} { }
  // ~A() = default; // Fixes GCC.
};

struct B {
  virtual ~B() = default;
};

inline constexpr auto x = A{B{}};
```

```
:10:32: error: 'virtual constexpr A::~A()' used before its
definition
   10 | inline constexpr auto x = A{B{}};
  |^
Compiler returned: 1
```

[Bug c++/106289] New: Value of polymorphic type as template argument

2022-07-13 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106289

Bug ID: 106289
   Summary: Value of polymorphic type as template argument
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/4jGn1fsc8.

```C++
struct B {
  virtual ~B() = default;
};

template long y;
long z = y;
```

```
:6:10: error: '((& B::_ZTV1B) + 16)' is not a valid template argument
for 'int (**)(...)' because it is not the address of a variable
6 | long z = y;
  |  ^~
Compiler returned: 1
```

[Bug c++/106304] New: [modules] ICE compiling dynamic_cast in constexpr function (in tree_node, at cp/module.cc:9183)

2022-07-14 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106304

Bug ID: 106304
   Summary: [modules] ICE compiling dynamic_cast in constexpr
function (in tree_node, at cp/module.cc:9183)
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/xz4Mhd8Wc, which Clang accepts:
https://godbolt.org/z/saachff5d.

mod.cpp:
```C++
export module mod;

template struct A : T {
  constexpr A(T v) : T{v} { }
  ~A() = default; // Fixes GCC.
};

struct B {
  virtual ~B() = default;
};

export inline constexpr auto x = A{B{}};

export constexpr const A* y(const B& b) {
  return dynamic_cast*>(&b);
}
```

test.cpp:
```C++
import mod;
static_assert(&x == y(x));
int main() { }
```

Output:
```
[ 50%] Building CXX object CMakeFiles/mod.dir/mod.cpp.o
mod.cpp:1:8: internal compiler error: in tree_node, at cp/module.cc:9183
1 | export module mod;
  |^~
0x221f229 internal_error(char const*, ...)
???:0
0x74c10d fancy_abort(char const*, int, char const*)
???:0
0x8fd00f trees_out::tree_node(tree_node*)
???:0
0x8fde5f trees_out::core_vals(tree_node*)
???:0
0x902d6d trees_out::tree_value(tree_node*)
???:0
0x8fcf41 trees_out::tree_node(tree_node*)
???:0
0x8fde5f trees_out::core_vals(tree_node*)
???:0
0x902d6d trees_out::tree_value(tree_node*)
???:0
0x8fcf41 trees_out::tree_node(tree_node*)
???:0
0x8fde5f trees_out::core_vals(tree_node*)
???:0
0x902d6d trees_out::tree_value(tree_node*)
???:0
0x8fcf41 trees_out::tree_node(tree_node*)
???:0
0x8fde5f trees_out::core_vals(tree_node*)
???:0
0x902d6d trees_out::tree_value(tree_node*)
???:0
0x8fcf41 trees_out::tree_node(tree_node*)
???:0
0x8fde5f trees_out::core_vals(tree_node*)
???:0
0x902d6d trees_out::tree_value(tree_node*)
???:0
0x8fcf41 trees_out::tree_node(tree_node*)
???:0
0x8fde5f trees_out::core_vals(tree_node*)
???:0
0x902d6d trees_out::tree_value(tree_node*)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c++/99377] [modules] undefined std::string_view::empty() if referenced in inline exported function

2022-07-16 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99377

--- Comment #8 from Johel Ernesto Guerrero Peña  ---
Created attachment 53309
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53309&action=edit
Debug GCM

[Bug c++/99377] [modules] undefined std::string_view::empty() if referenced in inline exported function

2022-07-16 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99377

--- Comment #9 from Johel Ernesto Guerrero Peña  ---
Created attachment 53310
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53310&action=edit
Debug object file

[Bug c++/99377] [modules] undefined std::string_view::empty() if referenced in inline exported function

2022-07-16 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99377

--- Comment #10 from Johel Ernesto Guerrero Peña  ---
Created attachment 53311
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53311&action=edit
Release GCM

[Bug c++/99377] [modules] undefined std::string_view::empty() if referenced in inline exported function

2022-07-16 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99377

--- Comment #11 from Johel Ernesto Guerrero Peña  ---
Created attachment 53312
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53312&action=edit
Release object file

[Bug c++/99377] [modules] undefined std::string_view::empty() if referenced in inline exported function

2022-07-16 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99377

--- Comment #12 from Johel Ernesto Guerrero Peña  ---
The workaround of Comment 5 stopped working for my actual use-case some time
ago. Now I do this:

```C++
export constexpr void expects(bool truth) noexcept {
  if (not truth) std::terminate();
}

// Workarounds GCC bug 99377.
export constexpr auto expects2 = expects;
```

FWIW, I've attached the debug and release `.gcm` and `.o` (without the
workaround above), which might hint as to what's (not) happening.

[Bug c++/99377] [modules] undefined std::string_view::empty() if referenced in inline exported function

2022-07-17 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99377

--- Comment #13 from Johel Ernesto Guerrero Peña  ---
> The workaround of Comment 5 stopped working for my actual use-case some time 
> ago.

The `using` declaration works if I move it earlier in the TU.

[Bug c++/95454] type-level nodiscard not applied to constructors

2022-07-19 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95454

--- Comment #3 from Johel Ernesto Guerrero Peña  ---
> A workaround would be to declare the constructor(s) [[nodiscard]]:

That's generally a [better
recommendation](https://github.com/mpusz/units/issues/136). Though I think
you'd have to `= default` SMFs to get the same effects as the  type-level
annotation.

[Bug c++/106363] New: [modules] Can't selectively reexport imported declaration in same namespace

2022-07-19 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106363

Bug ID: 106363
   Summary: [modules] Can't selectively reexport imported
declaration in same namespace
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Keywords: ice-on-valid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/a3GqTEs5P, which Clang accepts:
https://godbolt.org/z/svaGvz1bz.

mod2.cpp:
```C++
export module mod2;
namespace ns {
export int x = 0;
}
```

mod.cpp:
```C++
export module mod;
import mod2;
namespace ns {
export using ns::x;
}
```

test.cpp:
```C++
import mod;
int main() { return ns::x; }
```

Output:
```
[ 62%] Building CXX object CMakeFiles/mod.dir/mod.cpp.o
mod.cpp:1:8: internal compiler error: in decl_node, at cp/module.cc:8678
1 | export module mod;
  |^~
0x221f229 internal_error(char const*, ...)
???:0
0x74c10d fancy_abort(char const*, int, char const*)
???:0
0x8fcc60 trees_out::decl_node(tree_node*, walk_kind)
???:0
0x8fd01d trees_out::tree_node(tree_node*)
???:0
0x905086 module_state::write_cluster(elf_out*, depset**, unsigned int,
depset::hash&, unsigned int*, unsigned int*)
???:0
0x906ace module_state::write_begin(elf_out*, cpp_reader*, module_state_config&,
unsigned int&)
???:0
0x9079f2 finish_module_processing(cpp_reader*)
???:0
0x87253d c_parse_final_cleanups()
???:0
0xb2d060 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c++/101717] New: ICE capturing static member by ref within stateless lambda

2021-08-01 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101717

Bug ID: 101717
   Summary: ICE capturing static member by ref within stateless
lambda
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: ice-on-valid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/z4d4qhx8j.
```C++
struct x {
  static void f() noexcept { }
  void (*_)() = [] { [&](auto) { f(); }(0); };
};
```

[Bug c++/101717] ICE capturing static member within stateless generic lambda

2021-08-01 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101717

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

Summary|ICE capturing static member |ICE capturing static member
   |by ref within stateless |within stateless generic
   |lambda  |lambda

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
A bit simpler and a clarification: capturing at all within a generic stateless
lambda. https://godbolt.org/z/q11fT7MM8.
```C++
struct x {
  static void f() { }
  void (*_)() = [] { [=](auto) { f(); }(0); };
};
```

[Bug c++/101725] New: simple requirement of parameter in defaulted non-type template parameter considered non-dependent

2021-08-02 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101725

Bug ID: 101725
   Summary: simple requirement of parameter in defaulted non-type
template parameter considered non-dependent
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/fer6on13z.
```C++
template constexpr bool
can_x_yet{V};
template constexpr bool
can_y_yet{V};
```
The first line fails with:
```
:1:47: error: parameter 't' may not appear in this context
1 | template constexpr bool
can_x_yet{V};
  |   ^
:1:45: error: there are no arguments to 'x' that depend on a template
parameter, so a declaration of 'x' must be available [-fpermissive]
1 | template constexpr bool
can_x_yet{V};
  | ^
:1:45: note: (if you use '-fpermissive', G++ will accept your code, but
allowing the use of an undeclared name is deprecated)
Compiler returned: 1
```

[Bug c++/101733] New: simple-requirement prefixed with typename interpreted as type-requirement

2021-08-02 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101733

Bug ID: 101733
   Summary: simple-requirement prefixed with typename interpreted
as type-requirement
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/q67Mserar.
```C++
template
concept C = requires {
  typename T::x();
  typename T::x() + 1;
  1 + typename T::x();
};
```
```
:3:16: error: expected ';' before '(' token
3 |   typename T::x();
  |^
  |;
:4:16: error: expected ';' before '(' token
4 |   typename T::x() + 1;
  |^
  |;
Compiler returned: 1
```

[Bug c++/101764] New: ICE for constexpr if within fold expression within lambda expression within a template

2021-08-03 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101764

Bug ID: 101764
   Summary: ICE for constexpr if within fold expression within
lambda expression within a template
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/o944oWafx.
```C++
void f(auto i) {
  ([](T...) {
return (..., [] {
  if constexpr (T{0})
;
}());
  }(i));
}
void g() { f(0); }
```
```
: In instantiation of 'f(int):: [with T = {int}]':
:7:4:   required from 'void f(auto:1) [with auto:1 = int]'
:9:13:   required from here
:6:8: internal compiler error: in tsubst_pack_expansion, at
cp/pt.c:13102
6 | }());
  |^
0x1dadf09 internal_error(char const*, ...)
???:0
0x6e5511 fancy_abort(char const*, int, char const*)
???:0
0x962157 tsubst_pack_expansion(tree_node*, tree_node*, int, tree_node*)
???:0
0x94de47 instantiate_decl(tree_node*, bool, bool)
???:0
0x7f5dbe maybe_instantiate_decl(tree_node*)
???:0
0x7f7520 mark_used(tree_node*, int)
???:0
0x710ad5 build_op_call(tree_node*, vec**, int)
???:0
0x9b4935 finish_call_expr(tree_node*, vec**, bool,
bool, int)
???:0
0x94de47 instantiate_decl(tree_node*, bool, bool)
???:0
0x99020b instantiate_pending_templates(int)
???:0
0x7fb2f9 c_parse_final_cleanups()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1
```

[Bug c++/101884] New: Generic lambda with auto in template parameter list rejected

2021-08-12 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101884

Bug ID: 101884
   Summary: Generic lambda with auto in template parameter list
rejected
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/Go36onYGc.
```C++
templateint i;
```
```
:1:18: error: 'auto' parameter not permitted in this context
1 | templateint i;
  |  ^~~~
Compiler returned: 1
```

[Bug c++/102000] New: Defaulted consteval default constructor that performs no initialization is not rejected

2021-08-20 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102000

Bug ID: 102000
   Summary: Defaulted consteval default constructor that performs
no initialization is not rejected
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: accepts-invalid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/Te3nY7YeW and discussion at
https://cpplang.slack.com/archives/C21PKDHSL/p1629467874085000.
```C++
struct X{
  int i;
  consteval X() = default;
};
constexpr void f() {
  [[maybe_unused]] X x_f;
}
int main () {
  [[maybe_unused]] X x_main;
  []() consteval { f(); }();
}
```

```
An immediate invocation shall be a constant expression. --
https://eel.is/c++draft/expr.const#13.sentence-3

Lots of wording in between...

2 A variable or temporary object o is constant-initialized if
(2.1) either it has an initializer or its default-initialization results in
some initialization being performed, and
-- https://eel.is/c++draft/expr.const#2
7 To default-initialize an object of type T means:
(7.3) Otherwise, no initialization is performed.
-- https://eel.is/c++draft/dcl.init.general#7
```

```
[W]hether it's defaulted or not, `i` is uninitialized so it should reject both.
```

[Bug c++/102000] Defaulted consteval default constructor that performs no initialization is not rejected

2021-08-20 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102000

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
Can https://bugs.llvm.org/show_bug.cgi?id=51560 be fixed as part of this?

[Bug c++/102000] Defaulted consteval default constructor that performs no initialization is not rejected

2021-08-23 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102000

--- Comment #3 from Johel Ernesto Guerrero Peña  ---
https://bugs.llvm.org/show_bug.cgi?id=51560#c1 points out
> I'm not sure what you think the problem is here.  The constructor isn't 
> getting called; see http://eel.is/c++draft/dcl.init.general#8 .
It seems to me that they are right and the example above is well-formed.

[Bug c++/102050] New: Nonempty list-initialization rejects constructor with defaulted std::initializer_list

2021-08-24 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102050

Bug ID: 102050
   Summary: Nonempty list-initialization rejects constructor with
defaulted std::initializer_list
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/5PGza1o8e.
```C++
#include 
struct S { S( std::initializer_list = {} ) {} };
int main() { S{0}; }
```
```
: In function 'int main()':
:3:17: error: no matching function for call to 'S::S()'
3 | int main() { S{0}; }
  | ^
:2:12: note: candidate: 'S::S(std::initializer_list)'
2 | struct S { S( std::initializer_list = {} ) {} };
  |^
:2:15: note:   no known conversion for argument 1 from 'int' to
'std::initializer_list'
2 | struct S { S( std::initializer_list = {} ) {} };
  |   ^~~
:2:8: note: candidate: 'constexpr S::S(const S&)'
2 | struct S { S( std::initializer_list = {} ) {} };
  |^
:2:8: note:   no known conversion for argument 1 from 'int' to 'const
S&'
:2:8: note: candidate: 'constexpr S::S(S&&)'
:2:8: note:   no known conversion for argument 1 from 'int' to 'S&&'
Compiler returned: 1
```

This came up at https://cpplang.slack.com/archives/C2SLQATS9/p1629835850325200.

[Bug c++/110893] New: [modules] ICE Segmentation fault during GIMPLE pass modref

2023-08-03 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110893

Bug ID: 110893
   Summary: [modules] ICE Segmentation fault during GIMPLE pass
modref
   Product: gcc
   Version: 14.0
   URL: https://cpp2.godbolt.org/z/8q9c3P6vY
Status: UNCONFIRMED
  Keywords: ice-on-valid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

Please, see .
It has the source files,
and in the output,
the compile commands along with the errors.

```
$ cat module.cpp 
module;
#include 
export module hello;
export auto hello() -> std::string { return "Hello";  }
$ cat main.cpp 
#include 
import hello;
auto main() -> int { std::cout << hello() << ", modules!\n";  }
```

```
[1/6] /opt/compiler-explorer/clang-16.0.0/bin/clang-scan-deps -format=p1689 --
/opt/compiler-explorer/gcc-snapshot/bin/g++   -O3 -std=c++2b -pedantic-errors
-Wall -Wextra -Wconversion -Werror=unused-result -isystem
/opt/compiler-explorer/gcc-snapshot/bin/../lib/gcc/x86_64-linux-gnu/14.0.0/include
-x c++ /app/module.cpp -c -o CMakeFiles/main.dir/module.cpp.o -MT
CMakeFiles/main.dir/module.cpp.o.ddi -MD -MF
CMakeFiles/main.dir/module.cpp.o.ddi.d > CMakeFiles/main.dir/module.cpp.o.ddi
[2/6] /opt/compiler-explorer/clang-16.0.0/bin/clang-scan-deps -format=p1689 --
/opt/compiler-explorer/gcc-snapshot/bin/g++   -O3 -std=c++2b -pedantic-errors
-Wall -Wextra -Wconversion -Werror=unused-result -isystem
/opt/compiler-explorer/gcc-snapshot/bin/../lib/gcc/x86_64-linux-gnu/14.0.0/include
-x c++ /app/main.cpp -c -o CMakeFiles/main.dir/main.cpp.o -MT
CMakeFiles/main.dir/main.cpp.o.ddi -MD -MF CMakeFiles/main.dir/main.cpp.o.ddi.d
> CMakeFiles/main.dir/main.cpp.o.ddi
[3/6] /opt/compiler-explorer/cmake-v3.26.1/bin/cmake -E cmake_ninja_dyndep
--tdi=CMakeFiles/main.dir/CXXDependInfo.json --lang=CXX --modmapfmt=gcc
--dd=CMakeFiles/main.dir/CXX.dd @CMakeFiles/main.dir/CXX.dd.rsp
[4/6] /opt/compiler-explorer/gcc-snapshot/bin/g++   -O3 -std=c++2b
-pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -MD -MT
CMakeFiles/main.dir/module.cpp.o -MF CMakeFiles/main.dir/module.cpp.o.d
-fmodules-ts -Mno-modules
-fmodule-mapper=CMakeFiles/main.dir/module.cpp.o.modmap -x c++ -o
CMakeFiles/main.dir/module.cpp.o -c /app/module.cpp
[5/6] /opt/compiler-explorer/gcc-snapshot/bin/g++   -O3 -std=c++2b
-pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -MD -MT
CMakeFiles/main.dir/main.cpp.o -MF CMakeFiles/main.dir/main.cpp.o.d
-fmodules-ts -Mno-modules -fmodule-mapper=CMakeFiles/main.dir/main.cpp.o.modmap
-x c++ -o CMakeFiles/main.dir/main.cpp.o -c /app/main.cpp
FAILED: CMakeFiles/main.dir/main.cpp.o 
/opt/compiler-explorer/gcc-snapshot/bin/g++   -O3 -std=c++2b -pedantic-errors
-Wall -Wextra -Wconversion -Werror=unused-result -MD -MT
CMakeFiles/main.dir/main.cpp.o -MF CMakeFiles/main.dir/main.cpp.o.d
-fmodules-ts -Mno-modules -fmodule-mapper=CMakeFiles/main.dir/main.cpp.o.modmap
-x c++ -o CMakeFiles/main.dir/main.cpp.o -c /app/main.cpp
during GIMPLE pass: modref
main.cpp: In destructor 'constexpr
std::__cxx11::basic_string::_Alloc_hider::~_Alloc_hider()':
main.cpp:3:63: internal compiler error: Segmentation fault
3 | auto main() -> int { std::cout << hello() << ", modules!\n";  }
  |   ^
0x24732fe internal_error(char const*, ...)
???:0
0x1066600 walk_stmt_load_store_addr_ops(gimple*, void*, bool (*)(gimple*,
tree_node*, tree_node*, void*), bool (*)(gimple*, tree_node*, tree_node*,
void*), bool (*)(gimple*, tree_node*, tree_node*, void*))
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c++/110894] New: [modules] Program terminates with signal SIGSEGV

2023-08-03 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110894

Bug ID: 110894
   Summary: [modules] Program terminates with signal SIGSEGV
   Product: gcc
   Version: 14.0
   URL: https://cpp2.godbolt.org/z/7YrvenrzT
Status: UNCONFIRMED
  Keywords: wrong-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

Please, see .
It has the source files,
and in the output,
the compile commands along with the errors.

```
$ cat module.cpp 
module;
#include 
export module hello;
export auto hello() -> std::string { return "Hello";  }
$ cat main.cpp 
#include 
import hello;
auto main() -> int { std::cout << hello() << ", modules!\n";  }
```

```
[1/6] /opt/compiler-explorer/clang-16.0.0/bin/clang-scan-deps -format=p1689 --
/opt/compiler-explorer/gcc-snapshot/bin/g++   -O0 -std=c++2b -pedantic-errors
-Wall -Wextra -Wconversion -Werror=unused-result -isystem
/opt/compiler-explorer/gcc-snapshot/bin/../lib/gcc/x86_64-linux-gnu/14.0.0/include
-x c++ /app/module.cpp -c -o CMakeFiles/main.dir/module.cpp.o -MT
CMakeFiles/main.dir/module.cpp.o.ddi -MD -MF
CMakeFiles/main.dir/module.cpp.o.ddi.d > CMakeFiles/main.dir/module.cpp.o.ddi
[2/6] /opt/compiler-explorer/clang-16.0.0/bin/clang-scan-deps -format=p1689 --
/opt/compiler-explorer/gcc-snapshot/bin/g++   -O0 -std=c++2b -pedantic-errors
-Wall -Wextra -Wconversion -Werror=unused-result -isystem
/opt/compiler-explorer/gcc-snapshot/bin/../lib/gcc/x86_64-linux-gnu/14.0.0/include
-x c++ /app/main.cpp -c -o CMakeFiles/main.dir/main.cpp.o -MT
CMakeFiles/main.dir/main.cpp.o.ddi -MD -MF CMakeFiles/main.dir/main.cpp.o.ddi.d
> CMakeFiles/main.dir/main.cpp.o.ddi
[3/6] /opt/compiler-explorer/cmake-v3.26.1/bin/cmake -E cmake_ninja_dyndep
--tdi=CMakeFiles/main.dir/CXXDependInfo.json --lang=CXX --modmapfmt=gcc
--dd=CMakeFiles/main.dir/CXX.dd @CMakeFiles/main.dir/CXX.dd.rsp
[4/6] /opt/compiler-explorer/gcc-snapshot/bin/g++   -O0 -std=c++2b
-pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -MD -MT
CMakeFiles/main.dir/module.cpp.o -MF CMakeFiles/main.dir/module.cpp.o.d
-fmodules-ts -Mno-modules
-fmodule-mapper=CMakeFiles/main.dir/module.cpp.o.modmap -x c++ -o
CMakeFiles/main.dir/module.cpp.o -c /app/module.cpp
[5/6] /opt/compiler-explorer/gcc-snapshot/bin/g++   -O0 -std=c++2b
-pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -MD -MT
CMakeFiles/main.dir/main.cpp.o -MF CMakeFiles/main.dir/main.cpp.o.d
-fmodules-ts -Mno-modules -fmodule-mapper=CMakeFiles/main.dir/main.cpp.o.modmap
-x c++ -o CMakeFiles/main.dir/main.cpp.o -c /app/main.cpp
[6/6] : && /opt/compiler-explorer/gcc-snapshot/bin/g++ -O0 -std=c++2b
-pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -L/app
-Wl,-rpath,/app -Wl,-rpath,/opt/compiler-explorer/gcc-snapshot/lib64
-Wl,-rpath,/opt/compiler-explorer/gcc-snapshot/lib32
CMakeFiles/main.dir/main.cpp.o CMakeFiles/main.dir/module.cpp.o -o main   && :
Program returned: 139
Program terminated with signal: SIGSEGV
```

[Bug c++/110894] [modules] Program terminates with signal SIGSEGV

2023-08-03 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110894

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
If instead I use `std::string_view` in `-O3` (`-O0` works),
it also diagnoses ():

```
In file included from /app/module.cpp:2,
of module hello, imported at /app/main.cpp:2:
In member function 'constexpr const std::basic_string_view<_CharT,
_Traits>::value_type* std::basic_string_view<_CharT, _Traits>::data() const
[with _CharT = char; _Traits = std::char_traits]',
inlined from 'std::basic_ostream<_CharT, _Traits>&
std::operator<<(basic_ostream<_CharT, _Traits>&, basic_string_view<_CharT,
_Traits>) [with _CharT = char; _Traits = char_traits]' at
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/string_view:762:30,
inlined from 'int main()' at /app/main.cpp:3:46:
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/string_view:292:22:
warning: 'this' is used uninitialized [-Wuninitialized]
  292 |   { return this->_M_str; }
  |  ^~
In file included from
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/bits/basic_string.h:47,
 from
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/string:54,
 from
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/bits/locale_classes.h:40,
 from
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/bits/ios_base.h:41,
 from
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/ios:44,
 from
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/ostream:40,
 from
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/iostream:41,
 from /app/main.cpp:1:
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/string_view: In
function 'int main()':
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/string_view:760:5:
note: 'this' was declared here
  760 | operator<<(basic_ostream<_CharT, _Traits>& __os,
  | ^~~~
```

[Bug c++/110894] [modules] Program terminates with signal SIGSEGV

2023-08-03 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110894

--- Comment #3 from Johel Ernesto Guerrero Peña  ---
Reduced: .

If you comment out the use of `.data()` at the end of `my_string_view.hpp` it
works.
It originally comes from ``'s specialization of `hash`,
`  { return std::_Hash_impl::hash(__str.data(), __str.length()); }`.

[Bug c++/110978] New: [14 Regression] ICE lambda constrained with to-be-deduced object

2023-08-10 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110978

Bug ID: 110978
   Summary: [14 Regression] ICE lambda constrained with
to-be-deduced object
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Keywords: ice-on-invalid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See .

```C++
int f(int);
int main() {
  auto f = [](auto obj) requires requires { f(obj); } { return f(obj); }(0);
}
```

```output
: In function 'int main()':
:3:45: error: use of 'f' before deduction of 'auto'
3 |   auto f = [](auto obj) requires requires { f(obj); } { return f(obj);
}(0);
  | ^
:3:12: error: constraints on a non-templated function
3 |   auto f = [](auto obj) requires requires { f(obj); } { return f(obj);
}(0);
  |^
:3:53: internal compiler error: in dependent_type_p, at cp/pt.cc:27895
3 |   auto f = [](auto obj) requires requires { f(obj); } { return f(obj);
}(0);
  | ^
0x24742fe internal_error(char const*, ...)
???:0
0xaca188 fancy_abort(char const*, int, char const*)
???:0
0xb8c067 start_preparsed_function(tree_node*, tree_node*, int)
???:0
0xbeaac9 start_lambda_function(tree_node*, tree_node*)
???:0
0xcb0974 c_parse_file()
???:0
0xdf1599 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1
```

<    1   2   3   >