[Bug c++/102680] New: lambda-expression in template-argument plus templateed using leads to further using-directive being ignored within template scope

2021-10-10 Thread hq.ks at web dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102680

Bug ID: 102680
   Summary: lambda-expression in template-argument plus templateed
using leads to further using-directive being ignored
within template scope
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hq.ks at web dot de
  Target Milestone: ---

Created attachment 51581
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51581&action=edit
minimalist reproducer

Take:
0) a class template with two arguments
1) a templated using-directive containing a lambda-expression as a template
parameter to (0)
2) a using declaration within another template scope, which depends on template
parameters and makes use of (1)
3) any use of the type alias defined by (2)

With GCC 9.4.0, from my observation, the behavior is identical to the using
directive (2) not being there at all: it will complain about the alias not
naming a type, and if a conflicting definition of the same type is added, it
will accept it. (It will parse the RHS of (2) for errors, though.)

-Wall -Wextra does not turn up any warnings.

Generally, I would expect exactly one of the following to happen:
a) (2) gives a compiler error
b) Below (2), and in its scope, the alias is usable as a type name. 

I am not a C++ language lawyer, so I can't really vouch that my reproducer is
in fact valid C++20, but even if it is not, the principle of least surprise
would imply raising an error at (2). 

Cheers,
   Philipp

 > g++ --version # compiled from tarball
g++ (GCC) 9.4.0

 > uname -a
Linux hostname 4.9.0-15-amd64 #1 SMP Debian 4.9.258-1 (2021-03-08) x86_64
GNU/Linux

[Bug c++/102680] lambda-expression in template-argument plus templateed using leads to further using-directive being ignored within template scope

2021-10-10 Thread hq.ks at web dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102680

--- Comment #1 from hq.ks at web dot de ---
https://www.overleaf.com/learn/latex/Matrices

On 10/10/2021 20.51, pinskia at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102680
>
> Andrew Pinski  changed:
>
> What|Removed |Added
> 
> Keywords||accepts-invalid,
> ||rejects-valid
>

[Bug c++/102680] lambda-expression in template-argument plus templateed using leads to further using-directive being ignored within template scope

2021-10-10 Thread hq.ks at web dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102680

--- Comment #2 from hq.ks at web dot de ---
Ooops, terribly sorry, wanted to send that to someone else.


On 10/10/2021 20.56, Philipp Klenze wrote:
> https://www.overleaf.com/learn/latex/Matrices
> 
> On 10/10/2021 20.51, pinskia at gcc dot gnu.org wrote:
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102680
>>
>> Andrew Pinski  changed:
>>
>>     What    |Removed |Added
>>  
>>
>>     Keywords|    |accepts-invalid,
>>     |    |rejects-valid
>>

[Bug c++/102693] New: ICE in tsubst related to lambdas as template default parameters

2021-10-11 Thread hq.ks at web dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102693

Bug ID: 102693
   Summary: ICE in tsubst related to lambdas as template default
parameters
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hq.ks at web dot de
  Target Milestone: ---

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

Possible a duplicate of 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98500

but without template templates. 

> g++ -Wall -Wextra -std=gnu++2a -c template_def.cxx 
template_def.cxx: In instantiation of ‘int bar() [with bool b = true]’:
template_def.cxx:24:4:   required from here
template_def.cxx:2:18: internal compiler error: in tsubst, at cp/pt.c:14666
2 | template  // works fine if rhs is not a lambda
expression
  |  ^~
0x58c6c9 tsubst(tree_node*, tree_node*, int, tree_node*)
../.././gcc/cp/pt.c:14666
0x6d8985 tsubst_function_type
../.././gcc/cp/pt.c:14270
0x6c9ca4 tsubst(tree_node*, tree_node*, int, tree_node*)
../.././gcc/cp/pt.c:15110
0x6d96d5 tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
../.././gcc/cp/pt.c:18376
0x6cdf03 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../.././gcc/cp/pt.c:19820
0x6c0d1c tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../.././gcc/cp/pt.c:18131
0x6d1dc2 tsubst_template_args
../.././gcc/cp/pt.c:12670
0x6d6648 tsubst_aggr_type
../.././gcc/cp/pt.c:12867
0x6c9eff tsubst(tree_node*, tree_node*, int, tree_node*)
../.././gcc/cp/pt.c:14565
0x6d3de3 tsubst_decl
../.././gcc/cp/pt.c:13947
0x6ca127 tsubst(tree_node*, tree_node*, int, tree_node*)
../.././gcc/cp/pt.c:14483
0x6c2ac0 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../.././gcc/cp/pt.c:17307
0x6c14df tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../.././gcc/cp/pt.c:17222
0x6c1e01 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../.././gcc/cp/pt.c:17535
0x6c4d3d tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../.././gcc/cp/pt.c:17207
0x6c4d3d instantiate_decl(tree_node*, bool, bool)
../.././gcc/cp/pt.c:25053
0x6df923 instantiate_pending_templates(int)
../.././gcc/cp/pt.c:25169
0x638628 c_parse_final_cleanups()
../.././gcc/cp/decl2.c:4818
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.
 > g++ --version
g++ (GCC) 9.4.0
> uname -a
Linux ... 4.9.0-15-amd64 #1 SMP Debian 4.9.258-1 (2021-03-08) x86_64 GNU/Linux

[Bug c++/102693] ICE in tsubst related to lambdas as template default parameters

2021-10-11 Thread hq.ks at web dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102693

hq.ks at web dot de changed:

   What|Removed |Added

Version|unknown |9.4.0

--- Comment #1 from hq.ks at web dot de ---
Reproducer should say "if bar is not a template function" in the comment.

[Bug c/102694] New: no matching function for call when passing template-dependent template parameter to initialize literal class parameter

2021-10-11 Thread hq.ks at web dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102694

Bug ID: 102694
   Summary: no matching function for call when passing
template-dependent template parameter to initialize
literal class parameter
   Product: gcc
   Version: 9.4.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hq.ks at web dot de
  Target Milestone: ---

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

Sorry for the title. See code for details.

[Bug c++/102754] New: collisions in double constant template mangling for negative values

2021-10-14 Thread hq.ks at web dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102754

Bug ID: 102754
   Summary: collisions in double constant template mangling for
negative values
   Product: gcc
   Version: 9.4.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hq.ks at web dot de
  Target Milestone: ---

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

This was a weird one. 

C++ famously does not allow floating point numbers directly as template
parameters for unfathomable reasons (but lambda expressions returning double or
string constants are fine, go figure). The common workaround seems to be to
have a literal wrapper class which stores a FP number, can be initialized by
one and is convertable to one. 

When using this with negative double numbers, some came out all wrong from the
template, causing quite some confusion. 

Apparently, if two or more template instances depend on a double parameter
which is
a) negative
b) whose mantissa would fit into some 21 bits (possibly causing the 32 less
significant bits of the fraction part to be zero?)
any instance after the first one would erroneously refer to the first one. 

On further digging, I think this is somehow related to name mangling. 

For example, 3.0266874179647485e+267D (Binary 0x) will result
in an object named _ZTAXtl4wrapIdELdEEE for me. 
-1.486039738058660044846e-267 (aka 88 88 88 88 88 88 88 88), however, will
result in an object named _ZTAXtl4wrapIdELdEEE. 

Note how the upper 32 bits have all been replaced by ones! This means that any
doublewrap objects which have their sign bit set will collide if their lower 32
bits are the same. The case I encountered was just the special case of the
lower 32 bits being zero. 

Having concluded that, I can also conclude that this is a duplicate of
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98216 .
(Having spend a day to write up this bug report, I will still submit it and
then try to mark it as a duplicate. Hope that is okay.)

[Bug c++/102754] collisions in double constant template mangling for negative values

2021-10-14 Thread hq.ks at web dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102754

--- Comment #1 from hq.ks at web dot de ---
Created attachment 51602
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51602&action=edit
compile, grep object symbols

[Bug c++/102754] collisions in double constant template mangling for negative values

2021-10-14 Thread hq.ks at web dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102754

--- Comment #2 from hq.ks at web dot de ---
Created attachment 51603
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51603&action=edit
output

[Bug c++/102754] collisions in double constant template mangling for negative values

2021-10-14 Thread hq.ks at web dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102754

hq.ks at web dot de changed:

   What|Removed |Added

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

--- Comment #3 from hq.ks at web dot de ---
Marked as duplicate.

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

[Bug c++/98216] [C++20] template mangling for double template argument is wrong

2021-10-14 Thread hq.ks at web dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98216

hq.ks at web dot de changed:

   What|Removed |Added

 CC||hq.ks at web dot de

--- Comment #11 from hq.ks at web dot de ---
*** Bug 102754 has been marked as a duplicate of this bug. ***