Bug#985214: g++-11 internal error and fails to precompile a concept

2021-04-26 Thread Frank B. Brokken
Dear Matthias Klose, you wrote:
> 
> (2) now shows a proper error, as shown below.
> 
> Please could you report the other issues upstream?

OK.

-- 
Frank B. Brokken
(+31) 6 5353 2509
PGP Key Fingerprint: DF32 13DE B156 7732 E65E  3B4D 7DB2 A8BE EAE4 D8AA



Bug#985214: g++-11 internal error and fails to precompile a concept

2021-04-26 Thread Matthias Klose
(2) now shows a proper error, as shown below.

Please could you report the other issues upstream?


foo.cc: In substitution of ‘template  requires
OstreamInsertable void operator<<(CSVTabIns&&, con
st Type&) [with Type = FMT]’:
foo.cc:11:13:   required by substitution of ‘template  requires
OstreamInsertable void operator<<
(CSVTabIns&, const Type&) [with Type = FMT]’
foo.cc:46:22:   required from here
foo.cc:8:9:   required for the satisfaction of ‘OstreamInsertable’ [with
Type = FMT]
foo.cc:9:5:   in requirements with ‘std::ostream& out’, ‘Type value’ [with Type
= FMT]
foo.cc:9:5: error: satisfaction of atomic constraint ‘requires(std::ostream&
out, Type value) {out << value;} [with
Type = Type]’ depends on itself
9 | requires(std::ostream , Type value)
  | ^~~
   10 | {
  | ~
   11 | out << value;
  | ~
   12 | };
  | ~
foo.cc: In function ‘void operator<<(CSVTabIns&, FMT::FMTHline)’:
foo.cc:46:9: error: no match for ‘operator<<’ (operand types are ‘CSVTabIns’ and
‘FMT’)
   46 | tab << (*hline)(1);  // insert hline in the next column
  | ~~~ ^~ ~~~
  | |  |
  | CSVTabIns  FMT
foo.cc:40:13: note: candidate: ‘template  requires
OstreamInsertable void operator<<(CSVTabIns&&, const Type&)’
   40 | inline void operator<<(CSVTabIns &, Type const )
  | ^~~~
foo.cc:40:13: note:   template argument deduction/substitution failed:
foo.cc:40:13: note: constraints not satisfied
foo.cc: In substitution of ‘template  requires
OstreamInsertable void operator<<(CSVTabIns&&, const Type&) [with Type =
FMT]’:
foo.cc:11:13:   required by substitution of ‘template  requires
OstreamInsertable void operator<<(CSVTabIns&&, const Type&) [with Type = 
FMT]’
foo.cc:46:22:   required from here
foo.cc:8:9:   required for the satisfaction of ‘OstreamInsertable’ [with
Type = FMT]
foo.cc:9:5:   in requirements with ‘std::ostream& out’, ‘Type value’ [with Type
= FMT]
foo.cc:8:9:   required for the satisfaction of ‘OstreamInsertable’ [with
Type = FMT]
foo.cc:9:5:   in requirements with ‘std::ostream& out’, ‘Type value’ [with Type
= FMT]
foo.cc:9:5: error: satisfaction of atomic constraint ‘requires(std::ostream&
out, Type value) {out << value;} [with Type = Type]’ depends on itself
9 | requires(std::ostream , Type value)
  | ^~~
   10 | {
  | ~
   11 | out << value;
  | ~
   12 | };
  | ~
foo.cc: In substitution of ‘template  requires
OstreamInsertable void operator<<(CSVTabIns&&, const Type&) [with Type =
FMT]’:
foo.cc:11:13:   required by substitution of ‘template  requires
OstreamInsertable void operator<<(CSVTabIns&&, const Type&) [with Type = 
FMT]’
foo.cc:46:22:   required from here
foo.cc:8:9:   required for the satisfaction of ‘OstreamInsertable’ [with
Type = FMT]
foo.cc:9:5:   in requirements with ‘std::ostream& out’, ‘Type value’ [with Type
= FMT]
foo.cc:9:5: error: satisfaction of atomic constraint ‘requires(std::ostream&
out, Type value) {out << value;} [with Type = Type]’ depends on itself
foo.cc: In substitution of ‘template  requires
OstreamInsertable void operator<<(CSVTabIns&&, const Type&) [with Type =
FMT]’:
foo.cc:46:22:   required from here
foo.cc:11:13: note: the required expression ‘(out << value)’ is invalid
   11 | out << value;
  | ^~~~
cc1plus: note: set ‘-fconcepts-diagnostics-depth=’ to at least 2 for more detail
foo.cc:30:17: note: candidate: ‘template  requires
OstreamInsertable void operator<<(CSVTabIns&, const Type&)’
   30 | friend void operator<<(CSVTabIns , Type const );
  | ^~~~
foo.cc:30:17: note:   substitution of deduced template arguments resulted in
errors seen above
foo.cc:43:13: note: candidate: ‘void operator<<(CSVTabIns&, FMT::FMTHline)’
   43 | inline void operator<<(CSVTabIns , FMT::FMTHline hline)
  | ^~~~
foo.cc:43:54: note:   no known conversion for argument 2 from ‘FMT’ to
‘FMT::FMTHline’ {aka ‘FMT (*)(unsigned int)’}
   43 | inline void operator<<(CSVTabIns , FMT::FMTHline hline)
  |~~^



Bug#985214: g++-11 internal error and fails to precompile a concept

2021-03-14 Thread Frank Brokken
Package: g++-11
Version: 11-20210306-1
Severity: normal

Dear Maintainer,

   * What led up to the situation?

Following the installation of g++-11 a previously precompilable header file
can't be precompiled anymore, and in some cases the compiler reports an
internal error requesting to submit a bug report.

   * What exactly did you do (or not do) that was effective (or
 ineffective)?

After upgrading g++ to version 11.0.1 the compiler reports a problem when
precompiling the following header file (shown between the --
lines). Additional information is provided below the next *-ed question.

--
#ifndef INCLUDED_CSVTABINS_
#define INCLUDED_CSVTABINS_

// #include  instead of iosfwd makes no difference
#include 

template 
concept OstreamInsertable = 
requires(std::ostream , Type value)
{
out << value;
};

// when using typename instead of the above concept : no error(1)
// e.g., by activating the following #define
// #define OstreamInsertable typename

struct FMT
{
enum Align
{};

typedef FMT (*FMTFun)(unsigned, unsigned);
typedef FMT (*FMTHline)(unsigned);
};

class CSVTabIns
{
template 
friend void operator<<(CSVTabIns , Type const );

// when omitted: results in bugreport1  (2)
friend CSVTabIns <<(CSVTabIns , FMT const );   

friend void operator<<(CSVTabIns , FMT::FMTHline);
};

// when defined here: precompilation error  (3)
template 
inline void operator<<(CSVTabIns &, Type const )
{}

inline void operator<<(CSVTabIns , FMT::FMTHline hline)
{
// when the insertion is omitted: no precompilation error
tab << (*hline)(1);  // insert hline in the next column
}

// when defined here: no precompilation error   (4)
//template 
//inline void operator<<(CSVTabIns &, Type const )
//{}

#endif
--


   * What was the outcome of this action?

Points to note (see the (x) marked comment entries:

1: If the concept isn't used, but instead of using
'template '
the plain template header
'template '
is used compilation completes flawlessly.

Also, when using version 
g++-10 (Debian 10.2.1-6) 10.2.1 20210110
no problem is reported.


With g++-11 the received error message is:

csvtabins: In substitution of ‘template  requires  
OstreamOstreamInsertable void operator<<(CSVTabIns&&, const Type&) [with 
Type = FMT]’:
csvtabins:11:13:   required by substitution of ‘template  requires  
OstreamOstreamInsertable void operator<<(CSVTabIns&, const Type&) [with 
Type = FMT]’
csvtabins:45:22:   required from here
csvtabins:8:9:   required for the satisfaction of 
‘OstreamOstreamInsertable’ [with Type = FMT]
csvtabins:9:5:   in requirements with ‘std::ostream& out’, ‘Type value’ [with 
Type = FMT]
csvtabins:9:5: error: satisfaction of atomic constraint ‘requires(std::ostream& 
out, Type value) {out << value;} [with Type = Type]’ depends on itself
9 | requires(std::ostream , Type value)
  | ^~~
   10 | {
  | ~
   11 | out << value;
  | ~
   12 | };
  | ~

which, I'm afraid, doesn't help me to understand the nature of the
problem. In particular it's unclear what is meant by 'satisfaction of
atomic constraint ...  depends on itself'.

2: When the friend declaration below (2) is omitted, the compiler reports
an internal error requesting to submit a bug-report.
In particular, the compiler reports:

csvtabins:11:13: internal compiler error: in get, at cp/constraint.cc:2656
   11 | out << value;
...
0xc84ae6 tsubst_simple_requirement
../../src/gcc/cp/constraint.cc:1983
Please submit a full bug report,
with preprocessed source if appropriate.

To reduce the size of this bug-report: the compiler's full output can
be retrieved from 'https://www.icce.rug.nl/tmp/bugreport1'. The precompiled
header produced by the compiler when it generated bugreport1 can be retrieved
from 'https://www.icce.rug.nl/tmp/bugreport1-csvtabins.gch'.

When instead of g++-11 g++-10 (Debian 10.2.1-6) 10.2.1 20210110) is used
then no internal error emerges, but just a normal error about a missing
operator<<. E.g.:

csvtabins: In function ‘void operator<<(CSVTabIns&, FMT::FMTHline)’:
csvtabins:45:9: error: no match for ‘operator<<’ (operand types are ‘CSVTabIns’ 
and ‘FMT’)
   45 | tab << (*hline)(1);  // insert hline in the next column
  | ~~~ ^~ ~~~
  | |  |
  | CSVTabIns  FMT
...


3 and 4: Whether the compilation error is encountered or not depends on the
position of the 
template 
inline void operator<<(CSVTabIns &, Type const )
{}
template definition. When