はじめに(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.
12.2.4.3 Ranking implicit conversion sequences [over.ics.rank] C++N4910:2022 (189) p342.cpp
算譜(source code)
// 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 = "12.2.4.3 Ranking implicit conversion sequences [over.ics.rank] C++N4910:2022 (189) p342.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 f1(int);
void f1(std::initializer_list<long>);
void g1() {
f1({42});
}
void f2(std::pair<const char*, const char*>);
void f2(std::initializer_list<std::string>);
void g2() {
f2({"foo","bar"});
}
// #1
// #2
// chooses #2
// #3
// #4
// chooses #4
// [Example 2:
void f(int (&&)[] );
void f(double (&&)[] );
// #1 // #2 // #3
void f(int
(&&)[2]);
f( {1} );
f( {1.0} );
f( {1.0, 2.0} );
f( {1, 2} );
// Calls #1: Better than #2 due to conversion, better than #3 due to bounds
// Calls #2: Identity conversion is better than floating-integral conversion
// Calls #2: Identity conversion is better than floating-integral conversion
// Calls #3: Converting to array of known bound is better than to unknown bound, // and an identity conversion is better than floating-integral conversion
// [Example 3:
int i;
int f13();
int&& f23();
int g(const int&);
int g(const int&&);
int j = g(i);
int k = g(f13());
int l = g(f23());
struct A3 {
A3& operator<<(int);
void p() &;
void p() &&;
};
A3& operator<<(A&&, char);
A() << 1;
A3() << 'c';
A3 a;
a<<1;
a << 'c';
A3().p();
// calls g(const int&) // calls g(const int&&) // calls g(const int&&)
// calls A::operator<<(int)
// calls operator<<(A&&, char)
// calls A::operator<<(int) // calls A::operator<<(int) // calls A::p()&&
int f3(void(&)());
int f3(void(&&)());
void g3();
int i1 = f3(g3);
// #1 // #2
// calls #1
// [Example 5:
int f5(const volatile int *);
int f5(const int *);
int i;
int j = f5(&i);
// calls f(const int*)
// [Example 6:
int f6(const int &);
int f6(int &);
int g6(const int &);
int g6(int);
int i6;
int j = f6(i6);
int k = g6(i6);
struct X6 {
void f6() const;
void f6();
};
void g6(const X6& a6, X6 b6) {
a6.f6();
b6.f6();
// calls f(int &)
// ambiguous
// calls X::f() const
// calls X::f()
}
// [Example 7:
struct A7 {
operator short();
} a7;
int f7(int);
int f7(float);
int i7 = f7(a);
// calls f(int), because short → int is // better than short → float.
// [Example 8:
struct A8 {};
struct B8 : public A8 {};
struct C8 : public B8 {};
C8* pc;
int f8(A8*);
int f8(B8*);
int i8 = f8(pc);
// calls f(B*)
int main() {
cout << n4910 << endl;
return EXIT_SUCCESS;
}
Script
#!/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)
# ./clgc.sh p342
rm: cannot remove 'p342l': No such file or directory
rm: cannot remove 'p342g': No such file or directory
$ clang++ p342.cpp -std=c++03 -o p342l -I. -Wall
In file included from p342.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 \
^
p342.cpp:27:8: error: variable has incomplete type 'void'
void f1(std::initializer_list<long>);
^
p342.cpp:27:16: error: no member named 'initializer_list' in namespace 'std'
void f1(std::initializer_list<long>);
~~~~~^
p342.cpp:27:37: error: expected '(' for function-style cast or type construction
void f1(std::initializer_list<long>);
~~~~^
p342.cpp:27:38: error: expected expression
void f1(std::initializer_list<long>);
^
p342.cpp:28:18: error: expected expression
void g1() { f1({42}); }
^
p342.cpp:30:8: error: variable has incomplete type 'void'
void f2(std::initializer_list<std::string>);
^
p342.cpp:30:16: error: no member named 'initializer_list' in namespace 'std'
void f2(std::initializer_list<std::string>);
~~~~~^
p342.cpp:30:44: error: expected '(' for function-style cast or type construction
void f2(std::initializer_list<std::string>);
~~~~~~~~~~~^
p342.cpp:30:45: error: expected expression
void f2(std::initializer_list<std::string>);
^
p342.cpp:31:18: error: expected expression
void g2() { f2({"foo","bar"}); }
^
p342.cpp:39:18: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
void f(int (&&)[] );
^
p342.cpp:40:18: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
void f(double (&&)[] );
^
p342.cpp:43:2: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
(&&)[2]);
^
p342.cpp:44:1: error: C++ requires a type specifier for all declarations
f( {1} );
^
p342.cpp:44:4: error: expected expression
f( {1} );
^
p342.cpp:45:1: error: C++ requires a type specifier for all declarations
f( {1.0} );
^
p342.cpp:45:4: error: expected expression
f( {1.0} );
^
p342.cpp:46:1: error: C++ requires a type specifier for all declarations
f( {1.0, 2.0} );
^
p342.cpp:46:4: error: expected expression
f( {1.0, 2.0} );
^
p342.cpp:47:1: error: C++ requires a type specifier for all declarations
f( {1, 2} );
^
p342.cpp:47:4: error: expected expression
f( {1, 2} );
^
p342.cpp:55:6: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
int&& f23();
^
p342.cpp:57:18: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
int g(const int&&);
^
p342.cpp:63:14: warning: reference qualifiers on functions are a C++11 extension [-Wc++11-extensions]
void p() &;
^
p342.cpp:64:14: warning: reference qualifiers on functions are a C++11 extension [-Wc++11-extensions]
void p() &&;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
7 warnings and 20 errors generated.
rm: cannot remove 'p342l': No such file or directory
$ clang++ p342.cpp -std=c++2b -o p342l -I. -Wall
p342.cpp:44:1: error: C++ requires a type specifier for all declarations
f( {1} );
^
p342.cpp:45:1: error: C++ requires a type specifier for all declarations
f( {1.0} );
^
p342.cpp:46:1: error: C++ requires a type specifier for all declarations
f( {1.0, 2.0} );
^
p342.cpp:47:1: error: C++ requires a type specifier for all declarations
f( {1, 2} );
^
p342.cpp:66:16: error: unknown type name 'A'
A3& operator<<(A&&, char); A() << 1;
^
p342.cpp:66:32: error: expected function body after function declarator
A3& operator<<(A&&, char); A() << 1;
^
p342.cpp:67:4: error: expected unqualified-id
A3() << 'c';
^
p342.cpp:69:1: error: unknown type name 'a'
a<<1;
^
p342.cpp:69:2: error: expected unqualified-id
a<<1;
^
p342.cpp:70:1: error: unknown type name 'a'
a << 'c';
^
p342.cpp:70:3: error: expected unqualified-id
a << 'c';
^
p342.cpp:71:4: error: expected unqualified-id
A3().p();
^
p342.cpp:85:7: error: redefinition of 'i'
int i;
^
p342.cpp:53:7: note: previous definition is here
int i;
^
p342.cpp:86:7: error: redefinition of 'j'
int j = f5(&i);
^
p342.cpp:58:7: note: previous definition is here
int j = g(i);
^
p342.cpp:94:7: error: redefinition of 'j'
int j = f6(i6);
^
p342.cpp:58:7: note: previous definition is here
int j = g(i);
^
p342.cpp:95:7: error: redefinition of 'k'
int k = g6(i6);
^
p342.cpp:59:7: note: previous definition is here
int k = g(f13());
^
p342.cpp:95:11: error: call to 'g6' is ambiguous
int k = g6(i6);
^~
p342.cpp:91:7: note: candidate function
int g6(const int &);
^
p342.cpp:92:7: note: candidate function
int g6(int);
^
p342.cpp:114:12: error: no matching function for call to 'f7'
int i7 = f7(a);
^~
p342.cpp:112:7: note: candidate function not viable: no known conversion from 'A3' to 'int' for 1st argument
int f7(int);
^
p342.cpp:113:7: note: candidate function not viable: no known conversion from 'A3' to 'float' for 1st argument
int f7(float);
^
18 errors generated.
$ g++ p342.cpp -std=c++03 -o p342g -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
from p342.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 \
| ^~~~~
p342.cpp:27:8: error: variable or field 'f1' declared void
27 | void f1(std::initializer_list<long>);
| ^~
p342.cpp:27:16: error: 'initializer_list' is not a member of 'std'; did you mean 'uninitialized_fill'?
27 | void f1(std::initializer_list<long>);
| ^~~~~~~~~~~~~~~~
| uninitialized_fill
p342.cpp:27:33: error: expected primary-expression before 'long'
27 | void f1(std::initializer_list<long>);
| ^~~~
p342.cpp: In function 'void g1()':
p342.cpp:28:18: warning: extended initializer lists only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
28 | void g1() { f1({42}); }
| ^
p342.cpp: At global scope:
p342.cpp:30:8: error: variable or field 'f2' declared void
30 | void f2(std::initializer_list<std::string>);
| ^~
p342.cpp:30:16: error: 'initializer_list' is not a member of 'std'; did you mean 'uninitialized_fill'?
30 | void f2(std::initializer_list<std::string>);
| ^~~~~~~~~~~~~~~~
| uninitialized_fill
p342.cpp:30:44: error: expected primary-expression before '>' token
30 | void f2(std::initializer_list<std::string>);
| ^
p342.cpp:30:45: error: expected primary-expression before ')' token
30 | void f2(std::initializer_list<std::string>);
| ^
p342.cpp: In function 'void g2()':
p342.cpp:31:18: warning: extended initializer lists only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
31 | void g2() { f2({"foo","bar"}); }
| ^
p342.cpp: At global scope:
p342.cpp:39:8: error: variable or field 'f' declared void
39 | void f(int (&&)[] );
| ^
p342.cpp:39:10: error: expected primary-expression before 'int'
39 | void f(int (&&)[] );
| ^~~
p342.cpp:40:8: error: variable or field 'f' declared void
40 | void f(double (&&)[] );
| ^
p342.cpp:40:10: error: expected primary-expression before 'double'
40 | void f(double (&&)[] );
| ^~~~~~
p342.cpp:42:6: error: variable or field 'f' declared void
42 | void f(int
| ^
p342.cpp:42:8: error: expected primary-expression before 'int'
42 | void f(int
| ^~~
p342.cpp:44:2: error: expected constructor, destructor, or type conversion before '(' token
44 | f( {1} );
| ^
p342.cpp:44:8: error: expected unqualified-id before ')' token
44 | f( {1} );
| ^
p342.cpp:45:2: error: expected constructor, destructor, or type conversion before '(' token
45 | f( {1.0} );
| ^
p342.cpp:45:10: error: expected unqualified-id before ')' token
45 | f( {1.0} );
| ^
p342.cpp:46:2: error: expected constructor, destructor, or type conversion before '(' token
46 | f( {1.0, 2.0} );
| ^
p342.cpp:46:15: error: expected unqualified-id before ')' token
46 | f( {1.0, 2.0} );
| ^
p342.cpp:47:2: error: expected constructor, destructor, or type conversion before '(' token
47 | f( {1, 2} );
| ^
p342.cpp:47:11: error: expected unqualified-id before ')' token
47 | f( {1, 2} );
| ^
p342.cpp:55:6: error: expected unqualified-id before '&&' token
55 | int&& f23();
| ^~
p342.cpp:57:18: error: expected ',' or '...' before '&&' token
57 | int g(const int&&);
| ^~
p342.cpp:58:12: error: call of overloaded 'g(int&)' is ambiguous
58 | int j = g(i);
| ~^~~
p342.cpp:56:7: note: candidate: 'int g(const int&)'
56 | int g(const int&);
| ^
p342.cpp:57:7: note: candidate: 'int g(int)'
57 | int g(const int&&);
| ^
p342.cpp:59:12: error: call of overloaded 'g(int)' is ambiguous
59 | int k = g(f13());
| ~^~~~~~~
p342.cpp:56:7: note: candidate: 'int g(const int&)'
56 | int g(const int&);
| ^
p342.cpp:57:7: note: candidate: 'int g(int)'
57 | int g(const int&&);
| ^
p342.cpp:60:13: error: 'f23' was not declared in this scope; did you mean 'f2'?
60 | int l = g(f23());
| ^~~
| f2
p342.cpp:63:12: error: expected ';' at end of member declaration
63 | void p() &;
| ^
| ;
p342.cpp:63:15: error: expected unqualified-id before ';' token
63 | void p() &;
| ^
p342.cpp:64:12: error: expected ';' at end of member declaration
64 | void p() &&;
| ^
| ;
p342.cpp:64:10: error: 'void A3::p()' cannot be overloaded with 'void A3::p()'
64 | void p() &&;
| ^
p342.cpp:63:10: note: previous declaration 'void A3::p()'
63 | void p() &;
| ^
p342.cpp:64:14: error: expected unqualified-id before '&&' token
64 | void p() &&;
| ^~
p342.cpp:66:5: error: declaration of 'operator<<' as non-function
66 | A3& operator<<(A&&, char); A() << 1;
| ^~~~~~~~
p342.cpp:66:16: error: 'A' was not declared in this scope
66 | A3& operator<<(A&&, char); A() << 1;
| ^
p342.cpp:66:19: error: expected primary-expression before ',' token
66 | A3& operator<<(A&&, char); A() << 1;
| ^
p342.cpp:66:21: error: expected primary-expression before 'char'
66 | A3& operator<<(A&&, char); A() << 1;
| ^~~~
p342.cpp:66:32: error: expected constructor, destructor, or type conversion before '<<' token
66 | A3& operator<<(A&&, char); A() << 1;
| ^~
p342.cpp:67:4: error: expected unqualified-id before ')' token
67 | A3() << 'c';
| ^
p342.cpp:69:1: error: 'a' does not name a type
69 | a<<1;
| ^
p342.cpp:70:1: error: 'a' does not name a type
70 | a << 'c';
| ^
p342.cpp:71:4: error: expected unqualified-id before ')' token
71 | A3().p();
| ^
p342.cpp:77:14: error: 'int f3' redeclared as different kind of entity
77 | int f3(void(&&)());
| ^
p342.cpp:76:7: note: previous declaration 'int f3(void (&)())'
76 | int f3(void(&)());
| ^~
p342.cpp:77:10: error: expected primary-expression before 'void'
77 | int f3(void(&&)());
| ^~~~
p342.cpp:85:7: error: redefinition of 'int i'
85 | int i;
| ^
p342.cpp:53:7: note: 'int i' previously declared here
53 | int i;
| ^
p342.cpp:86:7: error: redefinition of 'int j'
86 | int j = f5(&i);
| ^
p342.cpp:58:7: note: 'int j' previously defined here
58 | int j = g(i);
| ^
p342.cpp:94:7: error: redefinition of 'int j'
94 | int j = f6(i6);
| ^
p342.cpp:58:7: note: 'int j' previously defined here
58 | int j = g(i);
| ^
p342.cpp:95:7: error: redefinition of 'int k'
95 | int k = g6(i6);
| ^
p342.cpp:59:7: note: 'int k' previously defined here
59 | int k = g(f13());
| ^
p342.cpp:95:13: error: call of overloaded 'g6(int&)' is ambiguous
95 | int k = g6(i6);
| ~~^~~~
p342.cpp:91:7: note: candidate: 'int g6(const int&)'
91 | int g6(const int &);
| ^~
p342.cpp:92:7: note: candidate: 'int g6(int)'
92 | int g6(int);
| ^~
p342.cpp:114:14: error: no matching function for call to 'f7(A3&)'
114 | int i7 = f7(a);
| ~~^~~
p342.cpp:112:7: note: candidate: 'int f7(int)'
112 | int f7(int);
| ^~
p342.cpp:112:10: note: no known conversion for argument 1 from 'A3' to 'int'
112 | int f7(int);
| ^~~
p342.cpp:113:7: note: candidate: 'int f7(float)'
113 | int f7(float);
| ^~
p342.cpp:113:10: note: no known conversion for argument 1 from 'A3' to 'float'
113 | int f7(float);
| ^~~~~
rm: cannot remove 'p342g': No such file or directory
$ g++ p342.cpp -std=c++2b -o p342g -I. -Wall
p342.cpp:44:2: error: expected constructor, destructor, or type conversion before '(' token
44 | f( {1} );
| ^
p342.cpp:44:8: error: expected unqualified-id before ')' token
44 | f( {1} );
| ^
p342.cpp:45:2: error: expected constructor, destructor, or type conversion before '(' token
45 | f( {1.0} );
| ^
p342.cpp:45:10: error: expected unqualified-id before ')' token
45 | f( {1.0} );
| ^
p342.cpp:46:2: error: expected constructor, destructor, or type conversion before '(' token
46 | f( {1.0, 2.0} );
| ^
p342.cpp:46:15: error: expected unqualified-id before ')' token
46 | f( {1.0, 2.0} );
| ^
p342.cpp:47:2: error: expected constructor, destructor, or type conversion before '(' token
47 | f( {1, 2} );
| ^
p342.cpp:47:11: error: expected unqualified-id before ')' token
47 | f( {1, 2} );
| ^
p342.cpp:66:5: error: declaration of 'operator<<' as non-function
66 | A3& operator<<(A&&, char); A() << 1;
| ^~~~~~~~
p342.cpp:66:16: error: 'A' was not declared in this scope
66 | A3& operator<<(A&&, char); A() << 1;
| ^
p342.cpp:66:19: error: expected primary-expression before ',' token
66 | A3& operator<<(A&&, char); A() << 1;
| ^
p342.cpp:66:21: error: expected primary-expression before 'char'
66 | A3& operator<<(A&&, char); A() << 1;
| ^~~~
p342.cpp:66:32: error: expected constructor, destructor, or type conversion before '<<' token
66 | A3& operator<<(A&&, char); A() << 1;
| ^~
p342.cpp:67:6: error: expected constructor, destructor, or type conversion before '<<' token
67 | A3() << 'c';
| ^~
p342.cpp:69:1: error: 'a' does not name a type
69 | a<<1;
| ^
p342.cpp:70:1: error: 'a' does not name a type
70 | a << 'c';
| ^
p342.cpp:71:5: error: expected constructor, destructor, or type conversion before '.' token
71 | A3().p();
| ^
p342.cpp:85:7: error: redefinition of 'int i'
85 | int i;
| ^
p342.cpp:53:7: note: 'int i' previously declared here
53 | int i;
| ^
p342.cpp:86:7: error: redefinition of 'int j'
86 | int j = f5(&i);
| ^
p342.cpp:58:7: note: 'int j' previously declared here
58 | int j = g(i);
| ^
p342.cpp:94:7: error: redefinition of 'int j'
94 | int j = f6(i6);
| ^
p342.cpp:58:7: note: 'int j' previously declared here
58 | int j = g(i);
| ^
p342.cpp:95:7: error: redefinition of 'int k'
95 | int k = g6(i6);
| ^
p342.cpp:59:7: note: 'int k' previously declared here
59 | int k = g(f13());
| ^
p342.cpp:95:13: error: call of overloaded 'g6(int&)' is ambiguous
95 | int k = g6(i6);
| ~~^~~~
p342.cpp:91:7: note: candidate: 'int g6(const int&)'
91 | int g6(const int &);
| ^~
p342.cpp:92:7: note: candidate: 'int g6(int)'
92 | int g6(int);
| ^~
p342.cpp:114:14: error: no matching function for call to 'f7(A3&)'
114 | int i7 = f7(a);
| ~~^~~
p342.cpp:112:7: note: candidate: 'int f7(int)'
112 | int f7(int);
| ^~
p342.cpp:112:10: note: no known conversion for argument 1 from 'A3' to 'int'
112 | int f7(int);
| ^~~
p342.cpp:113:7: note: candidate: 'int f7(float)'
113 | int f7(float);
| ^~
p342.cpp:113:10: note: no known conversion for argument 1 from 'A3' to 'float'
113 | int f7(float);
| ^~~~~
検討事項(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 初稿 20220702