LoginSignup
0
0

More than 1 year has passed since last update.

13.10.3.1 General [temp.deduct.general] C++N4910:2022 (239) p421.cpp

Last updated at Posted at 2022-07-06

はじめに(Introduction)

N4910 Working Draft, Standard for Programming Language C++

n4910は、ISO/IEC JTC1 SC22 WG21の作業原案(Working Draft)です。
公式のISO/IEC 14882原本ではありません。
ISO/IEC JTC1 SC22 WG21では、可能な限り作業文書を公開し、幅広い意見を求めています。
一連の記事はコード断片をコンパイルできる形にする方法を検討してコンパイル、リンク、実行して、規格案の原文と処理系(g++, Clang++)との違いを確認し、技術内容を検討し、ISO/IEC JTC1 SC22 WG21にフィードバックするために用います。
また、CERT C++, MISRA C++等のコーディング標準のコード断片をコンパイルする際の参考にさせていただこうと考えています。CERT C++, MISRA C++が標準化の動きとの時間的なずれがあれば確認できれば幸いです。また、boostライブラリとの関連、Linux OS, TOPPERSカーネル、g++(GCC), clang++(LLVM)との関係も調査中です。
何か、抜け漏れ、耳より情報がありましたらおしらせくださると幸いです。

<この項は書きかけです。順次追記します。>

背景(back ground)

C/C++でコンパイルエラーが出ると、途方にくれることがしばしばあります。
何回かに1回は、該当するエラーが検索できます。
ただ、条件が違っていて、そこでの修正方法では目的を達成しないこともしばしばです。いろいろな条件のコンパイルエラーとその対応方法について、広く記録することによって、いつか同じエラーに遭遇した時にやくに立つことを目指しています。

この半年の間で、三度、自分のネットでの記録に助けられたことがあります。
また過去に解決できなかった記録を10種類以上、最近になって解決できたことがあります。それは、主に次の3つの情報に基づいています。

https://stackoverflow.com
https://cpprefjp.github.io
http://ja.cppreference.com/

また
https://researchmap.jp/joub9b3my-1797580/#_1797580
に記載したサイトのお世話になっています。

作業方針(sequence)

Clang++では-std=c++03, C++2bの2種類
g++では-std=c++03, c++2bの2種類
でコンパイルし、

1)コンパイルエラーを収集する。
2)コンパイルエラーをなくす方法を検討する。
コンパイルエラーになる例を示すだけが目的のコードは、コンパイルエラーをなくすのではなく、コンパイルエラーの種類を収集するだけにする。
文法を示すのが目的のコード場合に、コンパイルエラーをなくすのに手間がかかる場合は、順次作業します。
3)リンクエラーをなくす方法を検討する。
文法を示すのが目的のコード場合に、リンクエラーをなくすのに手間がかかる場合は、順次作業します。
4)意味のある出力を作る。
コンパイル、リンクが通っても、意味のある出力を示そうとすると、コンパイル・リンクエラーが出て収拾できそうにない場合がある。順次作業します。

1)だけのものから4)まで進んだものと色々ある状態です。一歩でも前に進むご助言をお待ちしています。「検討事項」の欄に現状を記録するようにしています。

C++N4910:2022 Standard Working Draft on ISO/IEC 14882(0) sample code compile list

C++N4741, 2018 Standard Working Draft on ISO/IEC 14882 sample code compile list

C++N4606, 2016符号断片編纂一覧(example code compile list)

C++N4606, 2016 Working Draft 2016, ISO/IEC 14882, C++ standard(1) Example code compile list
https://qiita.com/kaizen_nagoya/items/df5d62c35bd6ed1c3d43/

C++N3242, 2011 sample code compile list on clang++ and g++

編纂器(Compiler)

clang++ --version

Debian clang version 14.0.5-++20220610033153+c12386ae247c-1~exp1~20220610153237.151
Target: x86_64-pc-linux-gnu, Thread model: posix, InstalledDir: /usr/bin

g++- --version

g++ (GCC) 12.1.0 Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

13.10.3.1 General [temp.deduct.general] C++N4910:2022 (239) p421.cpp

算譜(source code)

p421.cpp
// C++N4910 Committee Draft, Standard for Programming Language C++
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/n4910.pdf
const char * n4910 = "13.10.3.1 General [temp.deduct.general] C++N4910:2022 (239) p421.cpp";
// Debian clang version 14.0.5-++20220610033153+c12386ae247c-
// g++ (GCC) 12.1.0 Copyright (C) 2022 Free Software Foundation, Inc.
// Edited by Dr. Ogawa Kiyoshi. Compile procedure and results record.
// C++N4910:2022 Standard Working Draft on ISO/IEC 14882(0) sample code compile list
// https://qiita.com/kaizen_nagoya/items/fc957ddddd402004bb91

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <coroutine>
#include <vector>
#include <complex>
#include <map>
#include <atomic>
#include <unordered_map>
#include <typeinfo>

using namespace std;

// Example 1
void f(Array<dcomplex>& cv, Array<int>& ci) {
    sort(cv);
    sort(ci);
    void g(double d) {
        int i = convert<int>(d);
        int c = convert<char>(d);
    }
// cal ls // cal ls
// cal ls // cal ls
    sort(Array<dcomplex>&)
    sort(Array<int>&)
    convert<int,double>(double)
    convert<char,double>(double)
}
// and
// [Example 3:
template <class T> void f(T t);
template <class X> void g(const X x);
template <class Z> void h(Z, Z*);
int main3() {
// #1: function type is f(int), t is non const
    f<int>(1);
// #2: function type is f(int), t is const
    f<const int>(1);
// #3: function type is g(int), x is const
    g<int>(1);
// #4: function type is g(int), x is const
    g<const int>(1);
// #5: function type is h(int, const int*)
    h<const int>(1,0);
}
// [Example 4:
template <class T, class U = double>
void f(T t = 0, U u = 0);
void g() {
    f(1, 'c');
    f(1);
    f();
    f<int>();
    f<int,char>();
}
// f<int,char>(1,’c’)
// f<int,double>(1,0)
// error: T cannot be deduced // f<int,double>(0,0)
// f<int,char>(0,0)
// [Example 5:
template <class T> struct Z {
    typedef typename T::x xx;
};
template <class T> concept C = requires { typename T::A; };
template <C T> typename Z<T>::xx f(void *, T); // #1 template <class T> void f(int, T); // #2 struct A {} a;
struct ZZ {
    template <class T, class = typename Z<T>::xx> operator T *();
    operator int();
};
int main5() {
    ZZ zz;
    f(1, a);
    f(zz, 42);
// OK, deduction fails for #1 because there is no conversion from int to void* // OK, deduction fails for #1 because C<int> is not satisfied
}
// [Example 6:
template <class T> struct A {
    using X = typename T::X;
};
template <class T> typename T::X f(typename A<T>::X);
template <class T> void f(...) { }
template <class T> auto g(typename A<T>::X) -> typename T::X;
template <class T> void g(...) { }
template <class T> typename T::X h(typename A<T>::X);
template <class T> auto h(typename A<T>::X) -> typename T::X;
template <class T> void h(...) { }
// redeclaration
void x() {
    f<int>(0);
    g<int>(0);
    h<int>(0);
}
// OK, substituting return type causes deduction to fail
// error, substituting parameter type instantiates A<int>
// ill-formed, no diagnostic required
// [Example 7:
template <class T>
auto f(T) -> decltype([]() {
    T::invalid;
}
());
void f(...);
f(0); // error: invalid expression not part of the immediate context
template <class T, std::size_t = sizeof([]() {
    T::invalid;
})>
void g(T);
void g(...);
g(0); // error: invalid expression not part of the immediate context
template <class T>
auto h(T) -> decltype([x = T::invalid]() { });
void h(...);
h(0); // error: invalid expression not part of the immediate context
template <class T>
auto i(T) -> decltype([]() -> typename T::invalid { });
void i(...);
i(0); // error: invalid expression not part of the immediate context
template <class T>
auto j(T t) -> decltype([](auto x) -> decltype(x.invalid) { } (t));
// #1 // #2
void j(...);
j(0);
// [Example 8 :
struct X { };
struct Y {
    Y(X) {}
};
// deduction fails on #1, calls #2
template <class T> auto f(T t1, T t2) -> decltype(t1 + t2);
X f(Y, Y);
// #1 // #2
X x1, x2;
X x3 = f(x1, x2); // deduction fails on #1 (cannot add X+X), calls #2
// [Example 9:
template <class T> int f(T[5]);
int I = f<int>(0);
int j = f<void>(0);
// invalid array
// [Example 10:
template <class T> int f(typename T::B*);
int i = f<int> struct X { };
template <template <class T> class> struct Z { };
template <class T> void f(typename T::Y*) {}
template <class T> void g(X<T::N>*) {}
template <class T> void h(Z<T::TT>*) {}
struct A {};
struct B {
    int Y;
};
struct C {
    typedef int N;
};
struct D {
    typedef int TT;
};
int main10() {
    f<A>(0);
    f<B>(0);
    g<C>(0);
    h<D>(0);
}
// Deduction fails in each of these cases:
// [Example 12:
template <class T> int f(int T::*);
int i = f<int>(0);
// [Example 13:
template <class T, T> struct S {};
template <class T> int f(S<T, T()>*);
struct X {};
int i0 = f<X>(0);
// [Example 14:
template <class T, T*> int f(int);
int i2 = f<int,1>(0); // can’t conv 1 to int*
// A does not contain a member Y
// The Y member of B is not a type
// The N member of C is not a non-type // The TT member of D is not a template
// [Example 15: In the following example, assuming a signed char cannot represent the value 1000, a narrowing conversion(9.4.5)wouldberequiredtoconvertthetemplate-argumentoftypeinttosigned char,thereforesubstitution fails for the second template (13.4.3).
template <int> int f(int);
template <signed char> int f(int);
int i1 = f<1000>(0); // OK
int i2 = f<1>(0); // ambiguous; not narrowing
int main() {
    main3();
    main5();
    main10();
    cout  <<  n4910 << endl;
    return EXIT_SUCCESS;
}

Script

clgc.sh
#!/bin/sh
rm $1l
rm $1g
echo "$ clang++ $1.cpp -std=03 -o $1l -I. -Wall" 
clang++ $1.cpp -std=c++03 -o $1l -I. -Wall
if [  -e $1l ]; then
./$1l 
fi
rm $1l
echo "$ clang++ $1.cpp -std=2b -o $1l -I. -Wall"
clang++ $1.cpp -std=c++2b -o $1l -I. -Wall
if [  -e $1l ]; then
./$1l
fi
echo "\r"
echo "$ g++ $1.cpp -std=03 -o $1g -I. -Wall"
g++ $1.cpp -std=c++03 -o $1g -I. -Wall
if [ -e $1g ]; then
./$1g
fi
rm $1g
echo "\r"
echo "$ g++ $1.cpp -std=2b -o $1g -I. -Wall"
g++ $1.cpp -std=c++2b -o $1g -I. -Wall
if [ -e $1g ]; then
./$1g 
fi

編纂・実行結果(compile and go)

bash
# ./clgc.sh p421
rm: cannot remove 'p421l': No such file or directory
rm: cannot remove 'p421g': No such file or directory
$ clang++ p421.cpp -std=c++03 -o p421l -I. -Wall
In file included from p421.cpp:19:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/atomic:38:
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/c++0x_warning.h:32:2: error: This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support \
 ^
p421.cpp:26:14: error: use of undeclared identifier 'dcomplex'; did you mean 'complex'?
void f(Array<dcomplex>& cv, Array<int>& ci) {
             ^~~~~~~~
             complex
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:127:12: note: 'complex' declared here
    struct complex
           ^
p421.cpp:26:14: error: use of undeclared identifier 'dcomplex'; did you mean 'complex'?
void f(Array<dcomplex>& cv, Array<int>& ci) {
             ^~~~~~~~
             complex
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:127:12: note: 'complex' declared here
    struct complex
           ^
p421.cpp:26:14: error: use of undeclared identifier 'dcomplex'
void f(Array<dcomplex>& cv, Array<int>& ci) {
             ^
p421.cpp:26:29: error: no template named 'Array'
void f(Array<dcomplex>& cv, Array<int>& ci) {
                            ^
p421.cpp:29:20: error: function definition is not allowed here
  void g(double d) {
                   ^
p421.cpp:35:12: error: use of undeclared identifier 'dcomplex'; did you mean 'complex'?
sort(Array<dcomplex>&)
           ^~~~~~~~
           complex
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:127:12: note: 'complex' declared here
    struct complex
           ^
p421.cpp:35:12: error: use of undeclared identifier 'dcomplex'; did you mean 'complex'?
sort(Array<dcomplex>&)
           ^~~~~~~~
           complex
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:127:12: note: 'complex' declared here
    struct complex
           ^
p421.cpp:35:12: error: use of undeclared identifier 'dcomplex'
sort(Array<dcomplex>&)
           ^
p421.cpp:35:22: error: expected expression
sort(Array<dcomplex>&)
                     ^
p421.cpp:58:26: warning: default template arguments for a function template are a C++11 extension [-Wc++11-extensions]
template <class T, class U = double>
                         ^   ~~~~~~
p421.cpp:62:5: error: call to 'f' is ambiguous
    f(1);
    ^
p421.cpp:42:30: note: candidate function [with T = int]
     template <class T> void f(T t);
                             ^
p421.cpp:59:11: note: candidate function [with T = int, U = double]
     void f(T t = 0, U u = 0);
          ^
p421.cpp:63:5: error: no matching function for call to 'f'
    f();
    ^
p421.cpp:59:11: note: candidate template ignored: couldn't infer template argument 'T'
     void f(T t = 0, U u = 0);
          ^
p421.cpp:42:30: note: candidate function template not viable: requires single argument 't', but no arguments were provided
     template <class T> void f(T t);
                             ^
p421.cpp:75:20: error: unknown type name 'concept'
template <class T> concept C = requires { typename T::A; }; template <C T> typename Z<T>::xx f(void *, T); // #1 template <class T> void f(int, T); // #2 struct A {} a;
                   ^
p421.cpp:75:28: warning: variable templates are a C++14 extension [-Wc++14-extensions]
template <class T> concept C = requires { typename T::A; }; template <C T> typename Z<T>::xx f(void *, T); // #1 template <class T> void f(int, T); // #2 struct A {} a;
                           ^
p421.cpp:75:32: error: use of undeclared identifier 'requires'
template <class T> concept C = requires { typename T::A; }; template <C T> typename Z<T>::xx f(void *, T); // #1 template <class T> void f(int, T); // #2 struct A {} a;
                               ^
p421.cpp:75:40: error: expected ';' at end of declaration
template <class T> concept C = requires { typename T::A; }; template <C T> typename Z<T>::xx f(void *, T); // #1 template <class T> void f(int, T); // #2 struct A {} a;
                                       ^
                                       ;
p421.cpp:75:41: error: expected unqualified-id
template <class T> concept C = requires { typename T::A; }; template <C T> typename Z<T>::xx f(void *, T); // #1 template <class T> void f(int, T); // #2 struct A {} a;
                                        ^
p421.cpp:75:71: error: unknown type name 'C'
template <class T> concept C = requires { typename T::A; }; template <C T> typename Z<T>::xx f(void *, T); // #1 template <class T> void f(int, T); // #2 struct A {} a;
                                                                      ^
p421.cpp:75:87: error: template argument for template type parameter must be a type
template <class T> concept C = requires { typename T::A; }; template <C T> typename Z<T>::xx f(void *, T); // #1 template <class T> void f(int, T); // #2 struct A {} a;
                                                                                      ^
p421.cpp:72:19: note: template parameter is declared here
  template <class T> struct Z {
                  ^
p421.cpp:75:104: error: unknown type name 'T'
template <class T> concept C = requires { typename T::A; }; template <C T> typename Z<T>::xx f(void *, T); // #1 template <class T> void f(int, T); // #2 struct A {} a;
                                                                                                       ^
p421.cpp:77:30: warning: default template arguments for a function template are a C++11 extension [-Wc++11-extensions]
    template <class T, class = typename Z<T>::xx> operator T *();
                             ^ ~~~~~~~~~~~~~~~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
3 warnings and 20 errors generated.
rm: cannot remove 'p421l': No such file or directory
$ clang++ p421.cpp -std=c++2b -o p421l -I. -Wall
p421.cpp:26:14: error: use of undeclared identifier 'dcomplex'; did you mean 'complex'?
void f(Array<dcomplex>& cv, Array<int>& ci) {
             ^~~~~~~~
             complex
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:127:12: note: 'complex' declared here
    struct complex
           ^
p421.cpp:26:14: error: use of undeclared identifier 'dcomplex'; did you mean 'complex'?
void f(Array<dcomplex>& cv, Array<int>& ci) {
             ^~~~~~~~
             complex
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:127:12: note: 'complex' declared here
    struct complex
           ^
p421.cpp:26:14: error: use of undeclared identifier 'dcomplex'
void f(Array<dcomplex>& cv, Array<int>& ci) {
             ^
p421.cpp:26:29: error: no template named 'Array'; did you mean 'array'?
void f(Array<dcomplex>& cv, Array<int>& ci) {
                            ^~~~~
                            array
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/array:94:12: note: 'array' declared here
    struct array
           ^
p421.cpp:26:29: error: too few template arguments for class template 'array'
void f(Array<dcomplex>& cv, Array<int>& ci) {
                            ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/array:94:12: note: template is declared here
    struct array
           ^
p421.cpp:29:20: error: function definition is not allowed here
  void g(double d) {
                   ^
p421.cpp:35:12: error: use of undeclared identifier 'dcomplex'; did you mean 'complex'?
sort(Array<dcomplex>&)
           ^~~~~~~~
           complex
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:127:12: note: 'complex' declared here
    struct complex
           ^
p421.cpp:35:12: error: use of undeclared identifier 'dcomplex'; did you mean 'complex'?
sort(Array<dcomplex>&)
           ^~~~~~~~
           complex
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:127:12: note: 'complex' declared here
    struct complex
           ^
p421.cpp:35:12: error: use of undeclared identifier 'dcomplex'
sort(Array<dcomplex>&)
           ^
p421.cpp:35:22: error: expected expression
sort(Array<dcomplex>&)
                     ^
p421.cpp:62:5: error: call to 'f' is ambiguous
    f(1);
    ^
p421.cpp:42:30: note: candidate function [with T = int]
     template <class T> void f(T t);
                             ^
p421.cpp:59:11: note: candidate function [with T = int, U = double]
     void f(T t = 0, U u = 0);
          ^
p421.cpp:63:5: error: no matching function for call to 'f'
    f();
    ^
p421.cpp:59:11: note: candidate template ignored: couldn't infer template argument 'T'
     void f(T t = 0, U u = 0);
          ^
p421.cpp:42:30: note: candidate function template not viable: requires single argument 't', but no arguments were provided
     template <class T> void f(T t);
                             ^
p421.cpp:82:10: error: use of undeclared identifier 'a'
    f(1, a);
         ^
p421.cpp:73:22: error: type 'void' cannot be used prior to '::' because it has no members
    typedef typename T::x xx;
                     ^
p421.cpp:77:41: note: in instantiation of template class 'Z<void>' requested here
    template <class T, class = typename Z<T>::xx> operator T *();
                                        ^
p421.cpp:77:51: note: in instantiation of default argument for 'operator type-parameter-0-0 *<void>' required here
    template <class T, class = typename Z<T>::xx> operator T *();
                                                  ^~~~~~~~~~~~~~
p421.cpp:83:7: note: while substituting deduced template arguments into function template 'operator type-parameter-0-0 *' [with T = void, $1 = (no value)]
    f(zz, 42);
      ^
p421.cpp:83:5: note: while substituting deduced template arguments into function template 'f' [with T = int]
    f(zz, 42);
    ^
p421.cpp:97:5: error: call to 'f' is ambiguous
    f<int>(0);
    ^~~~~~
p421.cpp:42:30: note: candidate function [with T = int]
     template <class T> void f(T t);
                             ^
p421.cpp:59:11: note: candidate function [with T = int, U = double]
     void f(T t = 0, U u = 0);
          ^
p421.cpp:87:52: error: type 'int' cannot be used prior to '::' because it has no members
  template <class T> struct A { using X = typename T::X; };
                                                   ^
p421.cpp:90:38: note: in instantiation of template class 'A<int>' requested here
  template <class T> auto g(typename A<T>::X) -> typename T::X;
                                     ^
p421.cpp:98:5: note: while substituting explicitly-specified template arguments into function template 'g' 
    g<int>(0);
    ^
p421.cpp:108:1: error: C++ requires a type specifier for all declarations
f(0); // error: invalid expression not part of the immediate context
^
p421.cpp:112:1: error: C++ requires a type specifier for all declarations
g(0); // error: invalid expression not part of the immediate context
^
p421.cpp:116:1: error: C++ requires a type specifier for all declarations
h(0); // error: invalid expression not part of the immediate context
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

$ g++ p421.cpp -std=c++03 -o p421g -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
                 from p421.cpp:19:
/usr/local/include/c++/12.1.0/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
   32 | #error This file requires compiler and library support \
      |  ^~~~~
p421.cpp:106:21: warning: identifier 'decltype' is a keyword in C++11 [-Wc++11-compat]
  106 |        auto f(T) -> decltype([]() { T::invalid; } ());
      |                     ^~~~~~~~
p421.cpp:26:6: error: variable or field 'f' declared void
   26 | void f(Array<dcomplex>& cv, Array<int>& ci) {
      |      ^
p421.cpp:26:8: error: 'Array' was not declared in this scope
   26 | void f(Array<dcomplex>& cv, Array<int>& ci) {
      |        ^~~~~
p421.cpp:26:14: error: 'dcomplex' was not declared in this scope
   26 | void f(Array<dcomplex>& cv, Array<int>& ci) {
      |              ^~~~~~~~
p421.cpp:26:25: error: 'cv' was not declared in this scope
   26 | void f(Array<dcomplex>& cv, Array<int>& ci) {
      |                         ^~
p421.cpp:26:29: error: 'Array' was not declared in this scope
   26 | void f(Array<dcomplex>& cv, Array<int>& ci) {
      |                             ^~~~~
p421.cpp:26:35: error: expected primary-expression before 'int'
   26 | void f(Array<dcomplex>& cv, Array<int>& ci) {
      |                                   ^~~
p421.cpp: In function 'int main3()':
p421.cpp:56:6: warning: no return statement in function returning non-void [-Wreturn-type]
   56 |      }
      |      ^
p421.cpp: At global scope:
p421.cpp:59:29: error: default template arguments may not be used in function templates without '-std=c++11' or '-std=gnu++11'
   59 |      void f(T t = 0, U u = 0);
      |                             ^
p421.cpp: In function 'void g()':
p421.cpp:63:6: error: no matching function for call to 'f()'
   63 |     f();
      |     ~^~
p421.cpp:42:30: note: candidate: 'template<class T> void f(T)'
   42 |      template <class T> void f(T t);
      |                              ^
p421.cpp:42:30: note:   template argument deduction/substitution failed:
p421.cpp:63:6: note:   candidate expects 1 argument, 0 provided
   63 |     f();
      |     ~^~
p421.cpp:59:11: note: candidate: 'template<class T, class U> void f(T, U)'
   59 |      void f(T t = 0, U u = 0);
      |           ^
p421.cpp:59:11: note:   template argument deduction/substitution failed:
p421.cpp:63:6: note:   couldn't deduce template parameter 'T'
   63 |     f();
      |     ~^~
p421.cpp:64:11: error: no matching function for call to 'f<int>()'
   64 |     f<int>();
      |     ~~~~~~^~
p421.cpp:42:30: note: candidate: 'template<class T> void f(T)'
   42 |      template <class T> void f(T t);
      |                              ^
p421.cpp:42:30: note:   candidate expects 1 argument, 0 provided
p421.cpp:59:11: note: candidate: 'template<class T, class U> void f(T, U)'
   59 |      void f(T t = 0, U u = 0);
      |           ^
p421.cpp:59:11: note:   template argument deduction/substitution failed:
p421.cpp:64:11: note:   couldn't deduce template parameter 'U'
   64 |     f<int>();
      |     ~~~~~~^~
p421.cpp: At global scope:
p421.cpp:75:20: error: 'concept' does not name a type; did you mean 'const'?
   75 | template <class T> concept C = requires { typename T::A; }; template <C T> typename Z<T>::xx f(void *, T); // #1 template <class T> void f(int, T); // #2 struct A {} a;
      |                    ^~~~~~~
      |                    const
p421.cpp:75:20: note: 'concept' only available with '-std=c++20' or '-fconcepts'
p421.cpp:75:71: error: 'C' has not been declared
   75 | template <class T> concept C = requires { typename T::A; }; template <C T> typename Z<T>::xx f(void *, T); // #1 template <class T> void f(int, T); // #2 struct A {} a;
      |                                                                       ^
p421.cpp:75:87: error: 'T' was not declared in this scope
   75 | template <class T> concept C = requires { typename T::A; }; template <C T> typename Z<T>::xx f(void *, T); // #1 template <class T> void f(int, T); // #2 struct A {} a;
      |                                                                                       ^
p421.cpp:75:88: error: template argument 1 is invalid
   75 | template <class T> concept C = requires { typename T::A; }; template <C T> typename Z<T>::xx f(void *, T); // #1 template <class T> void f(int, T); // #2 struct A {} a;
      |                                                                                        ^
p421.cpp:75:104: error: 'T' has not been declared
   75 | template <class T> concept C = requires { typename T::A; }; template <C T> typename Z<T>::xx f(void *, T); // #1 template <class T> void f(int, T); // #2 struct A {} a;
      |                                                                                                        ^
p421.cpp:75:105: error: default template arguments may not be used in function templates without '-std=c++11' or '-std=gnu++11'
   75 | template <class T> concept C = requires { typename T::A; }; template <C T> typename Z<T>::xx f(void *, T); // #1 template <class T> void f(int, T); // #2 struct A {} a;
      |                                                                                                         ^
p421.cpp:77:64: error: default template arguments may not be used in function templates without '-std=c++11' or '-std=gnu++11'
   77 |     template <class T, class = typename Z<T>::xx> operator T *();
      |                                                                ^
p421.cpp: In function 'int main5()':
p421.cpp:82:10: error: 'a' was not declared in this scope
   82 |     f(1, a);
      |          ^
p421.cpp:85:1: warning: no return statement in function returning non-void [-Wreturn-type]
   85 | }
      | ^
p421.cpp: At global scope:
p421.cpp:87:39: error: expected nested-name-specifier before 'X'
   87 |   template <class T> struct A { using X = typename T::X; };
      |                                       ^
p421.cpp:90:22: warning: 'auto' changes meaning in C++11; please remove it [-Wc++11-compat]
   90 |   template <class T> auto g(typename A<T>::X) -> typename T::X;
      |                      ^~~~
      |                      ----
p421.cpp:90:27: error: ISO C++ forbids declaration of 'g' with no type [-fpermissive]
   90 |   template <class T> auto g(typename A<T>::X) -> typename T::X;
      |                           ^
p421.cpp:90:22: error: top-level declaration of 'g' specifies 'auto'
   90 |   template <class T> auto g(typename A<T>::X) -> typename T::X;
      |                      ^~~~
p421.cpp:90:62: error: trailing return type only available with '-std=c++11' or '-std=gnu++11'
   90 |   template <class T> auto g(typename A<T>::X) -> typename T::X;
      |                                                              ^
p421.cpp:93:22: warning: 'auto' changes meaning in C++11; please remove it [-Wc++11-compat]
   93 |   template <class T> auto h(typename A<T>::X) -> typename T::X;
      |                      ^~~~
      |                      ----
p421.cpp:93:27: error: ISO C++ forbids declaration of 'h' with no type [-fpermissive]
   93 |   template <class T> auto h(typename A<T>::X) -> typename T::X;
      |                           ^
p421.cpp:93:22: error: top-level declaration of 'h' specifies 'auto'
   93 |   template <class T> auto h(typename A<T>::X) -> typename T::X;
      |                      ^~~~
p421.cpp:93:62: error: trailing return type only available with '-std=c++11' or '-std=gnu++11'
   93 |   template <class T> auto h(typename A<T>::X) -> typename T::X;
      |                                                              ^
p421.cpp:106:8: warning: 'auto' changes meaning in C++11; please remove it [-Wc++11-compat]
  106 |        auto f(T) -> decltype([]() { T::invalid; } ());
      |        ^~~~
      |        ----
p421.cpp:106:21: error: expected type-specifier before 'decltype'
  106 |        auto f(T) -> decltype([]() { T::invalid; } ());
      |                     ^~~~~~~~
p421.cpp:106:21: error: expected initializer before 'decltype'
p421.cpp:106:52: error: expected unqualified-id before ')' token
  106 |        auto f(T) -> decltype([]() { T::invalid; } ());
      |                                                    ^
p421.cpp:108:2: error: expected constructor, destructor, or type conversion before '(' token
  108 | f(0); // error: invalid expression not part of the immediate context
      |  ^
p421.cpp:109:46: error: lambda-expression in unevaluated context only available with '-std=c++20' or '-std=gnu++20'
  109 |      template <class T, std::size_t = sizeof([]() { T::invalid; })>
      |                                              ^
p421.cpp:109:65: warning: lambda expressions only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
  109 |      template <class T, std::size_t = sizeof([]() { T::invalid; })>
      |                                                                 ^
p421.cpp:110:16: error: default template arguments may not be used in function templates without '-std=c++11' or '-std=gnu++11'
  110 |        void g(T);
      |                ^
p421.cpp:112:2: error: expected constructor, destructor, or type conversion before '(' token
  112 | g(0); // error: invalid expression not part of the immediate context
      |  ^
p421.cpp:114:8: warning: 'auto' changes meaning in C++11; please remove it [-Wc++11-compat]
  114 |        auto h(T) -> decltype([x = T::invalid]() { });
      |        ^~~~
      |        ----
p421.cpp:114:21: error: expected type-specifier before 'decltype'
  114 |        auto h(T) -> decltype([x = T::invalid]() { });
      |                     ^~~~~~~~
p421.cpp:114:21: error: expected initializer before 'decltype'
p421.cpp:114:52: error: expected unqualified-id before ')' token
  114 |        auto h(T) -> decltype([x = T::invalid]() { });
      |                                                    ^
p421.cpp:116:2: error: expected constructor, destructor, or type conversion before '(' token
  116 | h(0); // error: invalid expression not part of the immediate context
      |  ^
p421.cpp:118:8: warning: 'auto' changes meaning in C++11; please remove it [-Wc++11-compat]
  118 |        auto i(T) -> decltype([]() -> typename T::invalid { });
      |        ^~~~
      |        ----
p421.cpp:118:21: error: expected type-specifier before 'decltype'
  118 |        auto i(T) -> decltype([]() -> typename T::invalid { });
      |                     ^~~~~~~~
p421.cpp:118:21: error: expected initializer before 'decltype'
p421.cpp:118:61: error: expected unqualified-id before ')' token
  118 |        auto i(T) -> decltype([]() -> typename T::invalid { });
      |                                                             ^
p421.cpp:120:2: error: expected constructor, destructor, or type conversion before '(' token
  120 | i(0); // error: invalid expression not part of the immediate context
      |  ^
p421.cpp:122:3: warning: 'auto' changes meaning in C++11; please remove it [-Wc++11-compat]
  122 |   auto j(T t) -> decltype([](auto x) -> decltype(x.invalid) { } (t));
      |   ^~~~
      |   ----
p421.cpp:122:18: error: expected type-specifier before 'decltype'
  122 |   auto j(T t) -> decltype([](auto x) -> decltype(x.invalid) { } (t));
      |                  ^~~~~~~~
p421.cpp:122:18: error: expected initializer before 'decltype'
p421.cpp:122:68: error: expected constructor, destructor, or type conversion before ')' token
  122 |   auto j(T t) -> decltype([](auto x) -> decltype(x.invalid) { } (t));
      |                                                                    ^
p421.cpp:125:7: error: expected constructor, destructor, or type conversion before '(' token
  125 |      j(0);
      |       ^
p421.cpp:131:20: warning: 'auto' changes meaning in C++11; please remove it [-Wc++11-compat]
  131 | template <class T> auto f(T t1, T t2) -> decltype(t1 + t2);
      |                    ^~~~
      |                    ----
p421.cpp:131:42: error: expected type-specifier before 'decltype'
  131 | template <class T> auto f(T t1, T t2) -> decltype(t1 + t2);
      |                                          ^~~~~~~~
p421.cpp:131:42: error: expected initializer before 'decltype'
p421.cpp:135:9: error: conversion from 'void' to non-scalar type 'X' requested
  135 | X x3 = f(x1, x2); // deduction fails on #1 (cannot add X+X), calls #2
      |        ~^~~~~~~~
p421.cpp:138:22: error: void value not ignored as it ought to be
  138 |        int I = f<int>(0);
      |                ~~~~~~^~~
p421.cpp:139:12: error: 'int j' redeclared as different kind of entity
  139 |        int j = f<void>(0);
      |            ^
p421.cpp:124:11: note: previous declaration 'void j(...)'
  124 |      void j(...);
      |           ^
p421.cpp:143:10: error: 'int i' redeclared as different kind of entity
  143 |      int i = f<int> struct X { };
      |          ^
p421.cpp:119:6: note: previous declaration 'void i(...)'
  119 | void i(...);
      |      ^
p421.cpp:72:13: error: template parameter 'class T'
   72 |   template <class T> struct Z {
      |             ^~~~~
p421.cpp:144:35: note: redeclared here as 'template<class T> class<template-parameter-1-1>'
  144 |      template <template <class T> class> struct Z { };
      |                                   ^~~~~
p421.cpp:146:32: error: 'X' is not a template
  146 |      template <class T> void g(X<T::N>*) {}
      |                                ^
p421.cpp:147:39: error: to refer to a type member of a template parameter, use 'typename T::TT' [-fpermissive]
  147 |      template <class T> void h(Z<T::TT>*) {}
      |                                       ^
p421.cpp:148:13: error: class template 'A' redeclared as non-template
  148 |      struct A {};
      |             ^
p421.cpp:87:29: note: previous declaration here
   87 |   template <class T> struct A { using X = typename T::X; };
      |                             ^
p421.cpp: In function 'int main10()':
p421.cpp:157:5: error: no matching function for call to 'f<template<class T> struct A>(int)'
  157 | f<A>(0);
      | ~~~~^~~
p421.cpp:42:30: note: candidate: 'template<class T> void f(T)'
   42 |      template <class T> void f(T t);
      |                              ^
p421.cpp:42:30: note:   template argument deduction/substitution failed:
p421.cpp:157:5: error: type/value mismatch at argument 1 in template parameter list for 'template<class T> void f(T)'
  157 | f<A>(0);
      | ~~~~^~~
p421.cpp:157:5: note:   expected a type, got 'A'
p421.cpp:59:11: note: candidate: 'template<class T, class U> void f(T, U)'
   59 |      void f(T t = 0, U u = 0);
      |           ^
p421.cpp:59:11: note:   template argument deduction/substitution failed:
p421.cpp:157:5: error: type/value mismatch at argument 1 in template parameter list for 'template<class T, class U> void f(T, U)'
  157 | f<A>(0);
      | ~~~~^~~
p421.cpp:157:5: note:   expected a type, got 'A'
p421.cpp:75:94: note: candidate: 'template<<declaration error> > int f(void*, int)'
   75 | template <class T> concept C = requires { typename T::A; }; template <C T> typename Z<T>::xx f(void *, T); // #1 template <class T> void f(int, T); // #2 struct A {} a;
      |                                                                                              ^
p421.cpp:75:94: note:   candidate expects 2 arguments, 1 provided
p421.cpp:88:36: note: candidate: 'template<class T> typename T::X f(typename A<T>::X)'
   88 |   template <class T> typename T::X f(typename A<T>::X);
      |                                    ^
p421.cpp:88:36: note:   template argument deduction/substitution failed:
p421.cpp:157:5: error: type/value mismatch at argument 1 in template parameter list for 'template<class T> typename T::X f(typename A<T>::X)'
  157 | f<A>(0);
      | ~~~~^~~
p421.cpp:157:5: note:   expected a type, got 'A'
p421.cpp:89:27: note: candidate: 'template<class T> void f(...)'
   89 |   template <class T> void f(...) { }
      |                           ^
p421.cpp:89:27: note:   template argument deduction/substitution failed:
p421.cpp:157:5: error: type/value mismatch at argument 1 in template parameter list for 'template<class T> void f(...)'
  157 | f<A>(0);
      | ~~~~^~~
p421.cpp:157:5: note:   expected a type, got 'A'
p421.cpp:137:31: note: candidate: 'template<class T> int f(T*)'
  137 |        template <class T> int f(T[5]);
      |                               ^
p421.cpp:137:31: note:   template argument deduction/substitution failed:
p421.cpp:157:5: error: type/value mismatch at argument 1 in template parameter list for 'template<class T> int f(T*)'
  157 | f<A>(0);
      | ~~~~^~~
p421.cpp:157:5: note:   expected a type, got 'A'
p421.cpp:142:29: note: candidate: 'template<class T> int f(typename T::B*)'
  142 |      template <class T> int f(typename T::B*);
      |                             ^
p421.cpp:142:29: note:   template argument deduction/substitution failed:
p421.cpp:157:5: error: type/value mismatch at argument 1 in template parameter list for 'template<class T> int f(typename T::B*)'
  157 | f<A>(0);
      | ~~~~^~~
p421.cpp:157:5: note:   expected a type, got 'A'
p421.cpp:145:30: note: candidate: 'template<class T> void f(typename T::Y*)'
  145 |      template <class T> void f(typename T::Y*) {}
      |                              ^
p421.cpp:145:30: note:   template argument deduction/substitution failed:
p421.cpp:157:5: error: type/value mismatch at argument 1 in template parameter list for 'template<class T> void f(typename T::Y*)'
  157 | f<A>(0);
      | ~~~~^~~
p421.cpp:157:5: note:   expected a type, got 'A'
p421.cpp:161:1: warning: no return statement in function returning non-void [-Wreturn-type]
  161 | }
      | ^
p421.cpp: At global scope:
p421.cpp:165:10: error: 'int i' redeclared as different kind of entity
  165 |      int i = f<int>(0);
      |          ^
p421.cpp:119:6: note: previous declaration 'void i(...)'
  119 | void i(...);
      |      ^
p421.cpp:168:39: error: type/value mismatch at argument 2 in template parameter list for 'template<class T, T <anonymous> > struct S'
  168 |      template <class T> int f(S<T, T()>*);
      |                                       ^
p421.cpp:168:39: note:   expected a constant of type 'T', got 'T()'
p421.cpp:168:39: note:   ambiguous template argument for non-type template parameter is treated as function type
p421.cpp:169:13: error: redefinition of 'struct X'
  169 |      struct X {};
      |             ^
p421.cpp:127:13: note: previous definition of 'struct X'
  127 |      struct X { };
      |             ^
p421.cpp:170:19: error: call of overloaded 'f<X>(int)' is ambiguous
  170 |      int i0 = f<X>(0);
      |               ~~~~^~~
p421.cpp:89:27: note: candidate: 'void f(...) [with T = X]'
   89 |   template <class T> void f(...) { }
      |                           ^
p421.cpp:137:31: note: candidate: 'int f(T*) [with T = X]'
  137 |        template <class T> int f(T[5]);
      |                               ^
p421.cpp:164:24: note: candidate: 'int f(int T::*) [with T = X]'
  164 | template <class T> int f(int T::*);
      |                        ^
p421.cpp:168:29: note: candidate: 'int f(int*) [with T = X]'
  168 |      template <class T> int f(S<T, T()>*);
      |                             ^
p421.cpp:173:18: error: no matching function for call to 'f<int, 1>(int)'
  173 | int i2 = f<int,1>(0); // can’t conv 1 to int*
      |          ~~~~~~~~^~~
p421.cpp:42:30: note: candidate: 'template<class T> void f(T)'
   42 |      template <class T> void f(T t);
      |                              ^
p421.cpp:42:30: note:   template argument deduction/substitution failed:
p421.cpp:173:18: error: wrong number of template arguments (2, should be 1)
  173 | int i2 = f<int,1>(0); // can’t conv 1 to int*
      |          ~~~~~~~~^~~
p421.cpp:42:30: note: provided for 'template<class T> void f(T)'
   42 |      template <class T> void f(T t);
      |                              ^
p421.cpp:59:11: note: candidate: 'template<class T, class U> void f(T, U)'
   59 |      void f(T t = 0, U u = 0);
      |           ^
p421.cpp:59:11: note:   template argument deduction/substitution failed:
p421.cpp:173:18: error: type/value mismatch at argument 2 in template parameter list for 'template<class T, class U> void f(T, U)'
  173 | int i2 = f<int,1>(0); // can’t conv 1 to int*
      |          ~~~~~~~~^~~
p421.cpp:173:18: note:   expected a type, got '1'
p421.cpp:75:94: note: candidate: 'template<<declaration error> > int f(void*, int)'
   75 | template <class T> concept C = requires { typename T::A; }; template <C T> typename Z<T>::xx f(void *, T); // #1 template <class T> void f(int, T); // #2 struct A {} a;
      |                                                                                              ^
p421.cpp:75:94: note:   candidate expects 2 arguments, 1 provided
p421.cpp:88:36: note: candidate: 'template<class T> typename T::X f(typename A<T>::X)'
   88 |   template <class T> typename T::X f(typename A<T>::X);
      |                                    ^
p421.cpp:88:36: note:   template argument deduction/substitution failed:
p421.cpp:173:18: error: wrong number of template arguments (2, should be 1)
  173 | int i2 = f<int,1>(0); // can’t conv 1 to int*
      |          ~~~~~~~~^~~
p421.cpp:88:36: note: provided for 'template<class T> typename T::X f(typename A<T>::X)'
   88 |   template <class T> typename T::X f(typename A<T>::X);
      |                                    ^
p421.cpp:89:27: note: candidate: 'template<class T> void f(...)'
   89 |   template <class T> void f(...) { }
      |                           ^
p421.cpp:89:27: note:   template argument deduction/substitution failed:
p421.cpp:173:18: error: wrong number of template arguments (2, should be 1)
  173 | int i2 = f<int,1>(0); // can’t conv 1 to int*
      |          ~~~~~~~~^~~
p421.cpp:89:27: note: provided for 'template<class T> void f(...)'
   89 |   template <class T> void f(...) { }
      |                           ^
p421.cpp:137:31: note: candidate: 'template<class T> int f(T*)'
  137 |        template <class T> int f(T[5]);
      |                               ^
p421.cpp:137:31: note:   template argument deduction/substitution failed:
p421.cpp:173:18: error: wrong number of template arguments (2, should be 1)
  173 | int i2 = f<int,1>(0); // can’t conv 1 to int*
      |          ~~~~~~~~^~~
p421.cpp:137:31: note: provided for 'template<class T> int f(T*)'
  137 |        template <class T> int f(T[5]);
      |                               ^
p421.cpp:142:29: note: candidate: 'template<class T> int f(typename T::B*)'
  142 |      template <class T> int f(typename T::B*);
      |                             ^
p421.cpp:142:29: note:   template argument deduction/substitution failed:
p421.cpp:173:18: error: wrong number of template arguments (2, should be 1)
  173 | int i2 = f<int,1>(0); // can’t conv 1 to int*
      |          ~~~~~~~~^~~
p421.cpp:142:29: note: provided for 'template<class T> int f(typename T::B*)'
  142 |      template <class T> int f(typename T::B*);
      |                             ^
p421.cpp:145:30: note: candidate: 'template<class T> void f(typename T::Y*)'
  145 |      template <class T> void f(typename T::Y*) {}
      |                              ^
p421.cpp:145:30: note:   template argument deduction/substitution failed:
p421.cpp:173:18: error: wrong number of template arguments (2, should be 1)
  173 | int i2 = f<int,1>(0); // can’t conv 1 to int*
      |          ~~~~~~~~^~~
p421.cpp:145:30: note: provided for 'template<class T> void f(typename T::Y*)'
  145 |      template <class T> void f(typename T::Y*) {}
      |                              ^
p421.cpp:164:24: note: candidate: 'template<class T> int f(int T::*)'
  164 | template <class T> int f(int T::*);
      |                        ^
p421.cpp:164:24: note:   template argument deduction/substitution failed:
p421.cpp:173:18: error: wrong number of template arguments (2, should be 1)
  173 | int i2 = f<int,1>(0); // can’t conv 1 to int*
      |          ~~~~~~~~^~~
p421.cpp:164:24: note: provided for 'template<class T> int f(int T::*)'
  164 | template <class T> int f(int T::*);
      |                        ^
p421.cpp:168:29: note: candidate: 'template<class T> int f(int*)'
  168 |      template <class T> int f(S<T, T()>*);
      |                             ^
p421.cpp:168:29: note:   template argument deduction/substitution failed:
p421.cpp:173:18: error: wrong number of template arguments (2, should be 1)
  173 | int i2 = f<int,1>(0); // can’t conv 1 to int*
      |          ~~~~~~~~^~~
p421.cpp:168:29: note: provided for 'template<class T> int f(int*)'
  168 |      template <class T> int f(S<T, T()>*);
      |                             ^
p421.cpp:172:28: note: candidate: 'template<class T, T* <anonymous> > int f(int)'
  172 | template <class T, T*> int f(int);
      |                            ^
p421.cpp:172:28: note:   template argument deduction/substitution failed:
p421.cpp:173:18: error: could not convert template argument '1' from 'int' to 'int*'
  173 | int i2 = f<int,1>(0); // can’t conv 1 to int*
      |          ~~~~~~~~^~~
p421.cpp:180:17: error: call of overloaded 'f<1000>(int)' is ambiguous
  180 | int i1 = f<1000>(0); // OK
      |          ~~~~~~~^~~
p421.cpp:178:20: note: candidate: 'int f(int) [with int <anonymous> = 1000]'
  178 | template <int> int f(int);
      |                    ^
p421.cpp:179:28: note: candidate: 'int f(int) [with signed char <anonymous> = -24]'
  179 | template <signed char> int f(int);
      |                            ^
p421.cpp:181:5: error: redefinition of 'int i2'
  181 | int i2 = f<1>(0); // ambiguous; not narrowing
      |     ^~
p421.cpp:173:5: note: 'int i2' previously defined here
  173 | int i2 = f<int,1>(0); // can’t conv 1 to int*
      |     ^~
p421.cpp:181:14: error: call of overloaded 'f<1>(int)' is ambiguous
  181 | int i2 = f<1>(0); // ambiguous; not narrowing
      |          ~~~~^~~
p421.cpp:178:20: note: candidate: 'int f(int) [with int <anonymous> = 1]'
  178 | template <int> int f(int);
      |                    ^
p421.cpp:179:28: note: candidate: 'int f(int) [with signed char <anonymous> = 1]'
  179 | template <signed char> int f(int);
      |                            ^
rm: cannot remove 'p421g': No such file or directory

$ g++ p421.cpp -std=c++2b -o p421g -I. -Wall
p421.cpp:26:14: error: 'dcomplex' was not declared in this scope
   26 | void f(Array<dcomplex>& cv, Array<int>& ci) {
      |              ^~~~~~~~
p421.cpp:26:14: error: 'dcomplex' was not declared in this scope
p421.cpp:26:14: error: 'dcomplex' was not declared in this scope
p421.cpp:26:14: error: 'dcomplex' was not declared in this scope
p421.cpp:26:6: error: variable or field 'f' declared void
   26 | void f(Array<dcomplex>& cv, Array<int>& ci) {
      |      ^
p421.cpp:26:14: error: 'dcomplex' was not declared in this scope
   26 | void f(Array<dcomplex>& cv, Array<int>& ci) {
      |              ^~~~~~~~
p421.cpp:26:14: error: 'dcomplex' was not declared in this scope
p421.cpp:26:14: error: 'dcomplex' was not declared in this scope
p421.cpp:26:14: error: 'dcomplex' was not declared in this scope
p421.cpp:26:14: error: 'dcomplex' was not declared in this scope
p421.cpp:26:8: error: 'Array' was not declared in this scope
   26 | void f(Array<dcomplex>& cv, Array<int>& ci) {
      |        ^~~~~
p421.cpp:26:14: error: 'dcomplex' was not declared in this scope
   26 | void f(Array<dcomplex>& cv, Array<int>& ci) {
      |              ^~~~~~~~
p421.cpp:26:25: error: 'cv' was not declared in this scope
   26 | void f(Array<dcomplex>& cv, Array<int>& ci) {
      |                         ^~
p421.cpp:26:29: error: 'Array' was not declared in this scope
   26 | void f(Array<dcomplex>& cv, Array<int>& ci) {
      |                             ^~~~~
p421.cpp:26:35: error: expected primary-expression before 'int'
   26 | void f(Array<dcomplex>& cv, Array<int>& ci) {
      |                                   ^~~
p421.cpp: In function 'int main3()':
p421.cpp:56:6: warning: no return statement in function returning non-void [-Wreturn-type]
   56 |      }
      |      ^
p421.cpp: In function 'void g()':
p421.cpp:62:6: error: call of overloaded 'f(int)' is ambiguous
   62 |     f(1);
      |     ~^~~
p421.cpp:42:30: note: candidate: 'void f(T) [with T = int]'
   42 |      template <class T> void f(T t);
      |                              ^
p421.cpp:59:11: note: candidate: 'void f(T, U) [with T = int; U = double]'
   59 |      void f(T t = 0, U u = 0);
      |           ^
p421.cpp:63:6: error: no matching function for call to 'f()'
   63 |     f();
      |     ~^~
p421.cpp:42:30: note: candidate: 'template<class T> void f(T)'
   42 |      template <class T> void f(T t);
      |                              ^
p421.cpp:42:30: note:   template argument deduction/substitution failed:
p421.cpp:63:6: note:   candidate expects 1 argument, 0 provided
   63 |     f();
      |     ~^~
p421.cpp:59:11: note: candidate: 'template<class T, class U> void f(T, U)'
   59 |      void f(T t = 0, U u = 0);
      |           ^
p421.cpp:59:11: note:   template argument deduction/substitution failed:
p421.cpp:63:6: note:   couldn't deduce template parameter 'T'
   63 |     f();
      |     ~^~
p421.cpp: In function 'int main5()':
p421.cpp:82:10: error: 'a' was not declared in this scope
   82 |     f(1, a);
      |          ^
p421.cpp:85:1: warning: no return statement in function returning non-void [-Wreturn-type]
   85 | }
      | ^
p421.cpp: In function 'void x()':
p421.cpp:97:11: error: call of overloaded 'f<int>(int)' is ambiguous
   97 |     f<int>(0);
      |     ~~~~~~^~~
p421.cpp:42:30: note: candidate: 'void f(T) [with T = int]'
   42 |      template <class T> void f(T t);
      |                              ^
p421.cpp:59:11: note: candidate: 'void f(T, U) [with T = int; U = double]'
   59 |      void f(T t = 0, U u = 0);
      |           ^
p421.cpp:89:27: note: candidate: 'void f(...) [with T = int]'
   89 |   template <class T> void f(...) { }
      |                           ^
p421.cpp: In instantiation of 'struct A<int>':
p421.cpp:90:27:   required by substitution of 'template<class T> typename T::X g(typename A<T>::X) [with T = int]'
p421.cpp:98:11:   required from here
p421.cpp:87:39: error: 'int' is not a class, struct, or union type
   87 |   template <class T> struct A { using X = typename T::X; };
      |                                       ^
p421.cpp: At global scope:
p421.cpp:108:2: error: expected constructor, destructor, or type conversion before '(' token
  108 | f(0); // error: invalid expression not part of the immediate context
      |  ^
p421.cpp:112:2: error: expected constructor, destructor, or type conversion before '(' token
  112 | g(0); // error: invalid expression not part of the immediate context
      |  ^
p421.cpp:116:2: error: expected constructor, destructor, or type conversion before '(' token
  116 | h(0); // error: invalid expression not part of the immediate context
      |  ^
p421.cpp:120:2: error: expected constructor, destructor, or type conversion before '(' token
  120 | i(0); // error: invalid expression not part of the immediate context
      |  ^
p421.cpp:125:7: error: expected constructor, destructor, or type conversion before '(' token
  125 |      j(0);
      |       ^
p421.cpp:135:9: error: conversion from 'void' to non-scalar type 'X' requested
  135 | X x3 = f(x1, x2); // deduction fails on #1 (cannot add X+X), calls #2
      |        ~^~~~~~~~
p421.cpp: In substitution of 'template<class T> decltype (<lambda>()) f(T) [with T = int]':
p421.cpp:138:22:   required from here
p421.cpp:106:40: error: 'invalid' is not a member of 'int'
  106 |        auto f(T) -> decltype([]() { T::invalid; } ());
      |                                        ^~~~~~~
p421.cpp:138:22: error: call of overloaded 'f<int>(int)' is ambiguous
  138 |        int I = f<int>(0);
      |                ~~~~~~^~~
p421.cpp:42:30: note: candidate: 'void f(T) [with T = int]'
   42 |      template <class T> void f(T t);
      |                              ^
p421.cpp:59:11: note: candidate: 'void f(T, U) [with T = int; U = double]'
   59 |      void f(T t = 0, U u = 0);
      |           ^
p421.cpp:89:27: note: candidate: 'void f(...) [with T = int]'
   89 |   template <class T> void f(...) { }
      |                           ^
'
internal compiler error: error reporting routines re-entered.
0x1b9be5a error_at(unsigned int, char const*, ...)
	???:0
0x8b089b tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
	???:0
0x8ce0e8 tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
	???:0
0x8b103c tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
	???:0
0x8af675 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
	???:0
0x8b89c1 tsubst(tree_node*, tree_node*, int, tree_node*)
	???:0
0x1ba729c pp_format(pretty_printer*, text_info*)
	???:0
0x1b9af85 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
	???:0
0x1b9b87a inform(unsigned int, char const*, ...)
	???:0
0x75d154 build_new_function_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, int)
	???:0
0x8e4b38 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool, bool, int)
	???:0
0x89a369 c_parse_file()
	???:0
0x98412d 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 <https://gcc.gnu.org/bugs/> for instructions.

検討事項(agenda)

コンパイルエラーを取るか、コンパイルエラーの理由を解説する。

参考資料(reference)

cpprefjp - C++日本語リファレンス

コンパイラの実装状況

typedef は C++11 ではオワコン

C99からC++14を駆け抜けるC++講座

自己参照(self reference)

コピペコンパイルエラーあるある

C++ Error Message Collection(1)does not name a type, 11 articles

dockerにclang

docker gnu(gcc/g++) and llvm(clang/clang++)

コンパイル用shell script C版(clangとgcc)とC++版(clang++とg++)

Compare the contents of C++N4910:2022, C++N4741:2018 and C++N4606:2015

C++ sample list

clang++, g++コンパイルエラー方針の違いの例

astyle 使ってみた

C++N4606 Working Draft 2016, ISO/IEC 14882, C++ standardのコード断片をコンパイルするためにしていること
https://qiita.com/kaizen_nagoya/items/a8d7ee2f2e29e76c19c1

コンパイル用shell script C版(clangとgcc)とC++版(clang++とg++)
https://qiita.com/kaizen_nagoya/items/74220c0577a512c2d7da

Clang/Clang++(LLVM) gcc/g++(GNU) コンパイラ警告等比較
https://qiita.com/kaizen_nagoya/items/9a82b958cc3aeef0403f

C++2003とC++2017でコンパイルエラーになるならない事例集
https://qiita.com/kaizen_nagoya/items/a13ea3823441c430edff

Qiitaに投稿するCのStyle例(暫定)
https://qiita.com/kaizen_nagoya/items/946df1528a6a1ef2bc0d

cpprefjpのdecltypeをコンパイル試験
https://qiita.com/kaizen_nagoya/items/090909af702f0d5d8a67

MISRA C++ 5-0-16
https://qiita.com/kaizen_nagoya/items/7df2d4e05db724752a74

C++ Templates Part1 BASICS Chapter 3. Class Templates 3.2 Use of Class Template Stack stack1test.cpp
https://qiita.com/kaizen_nagoya/items/cd5fc49106fad5a4e9ed

ISO/IEC TS 17961:2013 C Secure Coding Rules(1) All list(to be confirmed)
https://qiita.com/kaizen_nagoya/items/54e056195c4f11b850a1

C言語(C++)に対する誤解、曲解、無理解、爽快。
https://qiita.com/kaizen_nagoya/items/3f3992c9722c1cee2e3a

C Puzzle Bookの有り難み5つ、C言語規格及びCコンパイラの特性を認識
https://qiita.com/kaizen_nagoya/items/d89a48c1536a02ecdec9

'wchar.h' file not found で困った clang++ macOS
https://qiita.com/kaizen_nagoya/items/de15cd46d657517fac11

Open POSIX Test Suiteの使い方を調べはじめました
https://qiita.com/kaizen_nagoya/items/644d5e407f5faf96e6dc

MISRA-C 2012 Referenceに掲載している文献の入手可能性を確認
https://qiita.com/kaizen_nagoya/items/96dc8b125e462d5575bb

どうやって MISRA Example Suiteをコンパイルするか
https://qiita.com/kaizen_nagoya/items/fbdbff5ff696e2ca7f00

MISRA C まとめ #include
https://qiita.com/kaizen_nagoya/items/f1a79a7cbd281607c7c9

「C++完全理解ガイド」の同意できること上位10
https://qiita.com/kaizen_nagoya/items/aa5744e0c4a8618c7671

<この記事は個人の過去の経験に基づく個人の感想です。現在所属する組織、業務とは関係がありません。>

文書履歴(document history)

ver. 0.01 初稿  20220706

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0