The C++ Standard Library - A Tutorial and Reference, 2nd Edition by Nicolai M. Josuttis
http://cppstdlib.com
The C++ Standard Library: clang++とg++でコンパイルしてみた(まとめ)
https://qiita.com/kaizen_nagoya/items/9bdfaa392443d13e5759
目的(purpose)
The C++ Standard Libraryコンパイル記録は、コンパイラおよび対応標準、コンパイラの版により、コンパイルエラーMessageの違いを記録し、どのエラーが出たら、どの版またはどの対応標準にすればエラーが少なくなるかを考察するための資料の第一歩です。
成果(outcome)
(1)コンパイラの種類、対応標準の違いによってエラーの数が違う。
(2)同じエラーであってもMessageの表現が違う。
(3) Error Messageのネットで検索する際に役立つ。
編纂器(compiler)
clang++
clang version 6.0.0 (tags/RELEASE_600/final)
Target: x86_64-apple-darwin17.5.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
g++
g++ (Homebrew GCC 8.1.0) 8.1.0
Copyright (C) 2018 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.
編纂実行(compile and go)
##stl
clang++ ./stl/add1.cpp -std=c++2a -Wall
initialized: 1 2 3 4 5 6 7 8 9
after adding 10: 11 12 13 14 15 16 17 18 19
after adding first element: 22 23 24 25 26 27 28 29 30
g++ ./stl/add1.cpp -std=c++2a -Wall
initialized: 1 2 3 4 5 6 7 8 9
after adding 10: 11 12 13 14 15 16 17 18 19
after adding first element: 22 23 24 25 26 27 28 29 30
clang++ ./stl/algo1.cpp -std=c++2a -Wall
min: 1
max: 6
1 2 6 5 4 3
g++ ./stl/algo1.cpp -std=c++2a -Wall
min: 1
max: 6
1 2 6 5 4 3
clang++ ./stl/algo1old.cpp -std=c++2a -Wall
min: 1
max: 6
1 2 6 5 4 3
g++ ./stl/algo1old.cpp -std=c++2a -Wall
min: 1
max: 6
1 2 6 5 4 3
clang++ ./stl/array1.cpp -std=c++2a -Wall
0: hello
1: world
2:
3:
4:
g++ ./stl/array1.cpp -std=c++2a -Wall
./stl/array1.cpp: In function 'int main()':
./stl/array1.cpp:22:20: warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Wsign-compare]
for (int i=0; i<coll.size(); ++i) {
~^~~~~~~~~~~~
0: hello
1: world
2:
3:
4:
clang++ ./stl/assoarray1.cpp -std=c++2a -Wall
VAT difference: 0.12
g++ ./stl/assoarray1.cpp -std=c++2a -Wall
VAT difference: 0.12
clang++ ./stl/bind1.cpp -std=c++2a -Wall
initialized: 9 8 7 6 5 4 3 2 1
transformed: 90 80 70 60 50 40 30 20 10
replaced: 90 80 42 60 50 40 30 20 10
removed: 90 42 40 30 20 10
g++ ./stl/bind1.cpp -std=c++2a -Wall
initialized: 9 8 7 6 5 4 3 2 1
transformed: 90 80 70 60 50 40 30 20 10
replaced: 90 80 42 60 50 40 30 20 10
removed: 90 42 40 30 20 10
clang++ ./stl/copy1.cpp -std=c++2a -Wall
g++ ./stl/copy1.cpp -std=c++2a -Wall
clang++ ./stl/copy2.cpp -std=c++2a -Wall
g++ ./stl/copy2.cpp -std=c++2a -Wall
clang++ ./stl/copybug.cpp -std=c++2a -Wall
./cga.sh: line 16: 4126 Segmentation fault: 11 ./a.out
g++ ./stl/copybug.cpp -std=c++2a -Wall
./cga.sh: line 16: 4136 Segmentation fault: 11 ./a.out
clang++ ./stl/deque1.cpp -std=c++2a -Wall
6.6 5.5 4.4 3.3 2.2 1.1
g++ ./stl/deque1.cpp -std=c++2a -Wall
./stl/deque1.cpp: In function 'int main()':
./stl/deque1.cpp:25:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<float>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
for (int i=0; i<coll.size(); ++i) {
~^~~~~~~~~~~~
6.6 5.5 4.4 3.3 2.2 1.1
clang++ ./stl/find1.cpp -std=c++2a -Wall
max: 34
max: 35
g++ ./stl/find1.cpp -std=c++2a -Wall
max: 34
max: 35
clang++ ./stl/fo1.cpp -std=c++2a -Wall
initialized: 1 2 3 5 7 11 13 17 19
negated: -1 -2 -3 -5 -7 -11 -13 -17 -19
squared: 1 4 9 25 49 121 169 289 361
g++ ./stl/fo1.cpp -std=c++2a -Wall
initialized: 1 2 3 5 7 11 13 17 19
negated: -1 -2 -3 -5 -7 -11 -13 -17 -19
squared: 1 4 9 25 49 121 169 289 361
clang++ ./stl/foreach1.cpp -std=c++2a -Wall
1 2 3 4 5 6 7 8 9
g++ ./stl/foreach1.cpp -std=c++2a -Wall
1 2 3 4 5 6 7 8 9
clang++ ./stl/foreach2.cpp -std=c++2a -Wall
1 2 3 4 5 6 7 8 9
g++ ./stl/foreach2.cpp -std=c++2a -Wall
1 2 3 4 5 6 7 8 9
clang++ ./stl/forwardlist1.cpp -std=c++2a -Wall
2 3 5 7 11 13 17 0 0 99
g++ ./stl/forwardlist1.cpp -std=c++2a -Wall
2 3 5 7 11 13 17 0 0 99
clang++ ./stl/ioiter1.cpp -std=c++2a -Wall
g++ ./stl/ioiter1.cpp -std=c++2a -Wall
$ ../cga.sh stl2
clang++ iterbug.cpp -std=c++2a -Wall
../cga.sh: line 16: 9983 Segmentation fault: 11 ./$line.exe
g++ iterbug.cpp -std=c++2a -Wall
../cga.sh: line 16: 9993 Segmentation fault: 11 ./$line.exe
clang++ lambda1.cpp -std=c++2a -Wall
first elem >5 and <12: 7
g++ lambda1.cpp -std=c++2a -Wall
first elem >5 and <12: 7
clang++ list1.cpp -std=c++2a -Wall
a b c d e f g h i j k l m n o p q r s t u v w x y z
g++ list1.cpp -std=c++2a -Wall
a b c d e f g h i j k l m n o p q r s t u v w x y z
clang++ list1old.cpp -std=c++2a -Wall
a b c d e f g h i j k l m n o p q r s t u v w x y z
g++ list1old.cpp -std=c++2a -Wall
a b c d e f g h i j k l m n o p q r s t u v w x y z
clang++ list2.cpp -std=c++2a -Wall
a b c d e f g h i j k l m n o p q r s t u v w x y z
g++ list2.cpp -std=c++2a -Wall
a b c d e f g h i j k l m n o p q r s t u v w x y z
clang++ multimap1.cpp -std=c++2a -Wall
this is a multimap of tagged strings
g++ multimap1.cpp -std=c++2a -Wall
this is a multimap of tagged strings
clang++ multiset1.cpp -std=c++2a -Wall
Braunschweig Chicago Frankfurt Frankfurt Hanover New York Paris Toronto
Braunschweig Braunschweig Chicago Frankfurt Frankfurt Hanover Hanover London Munich New York Paris Toronto
g++ multiset1.cpp -std=c++2a -Wall
Braunschweig Chicago Frankfurt Frankfurt Hanover New York Paris Toronto
Braunschweig Braunschweig Chicago Frankfurt Frankfurt Hanover Hanover London Munich New York Paris Toronto
clang++ prime1.cpp -std=c++2a -Wall
29 is first prime number found
g++ prime1.cpp -std=c++2a -Wall
29 is first prime number found
clang++ remove1.cpp -std=c++2a -Wall
pre: 6 5 4 3 2 1 1 2 3 4 5 6
post: 6 5 4 2 1 1 2 4 5 6 5 6
g++ remove1.cpp -std=c++2a -Wall
pre: 6 5 4 3 2 1 1 2 3 4 5 6
post: 6 5 4 2 1 1 2 4 5 6 5 6
clang++ remove2.cpp -std=c++2a -Wall
6 5 4 3 2 1 1 2 3 4 5 6
6 5 4 2 1 1 2 4 5 6
number of removed elements: 2
6 5 4 2 1 1 2 4 5 6
g++ remove2.cpp -std=c++2a -Wall
6 5 4 3 2 1 1 2 3 4 5 6
6 5 4 2 1 1 2 4 5 6
number of removed elements: 2
6 5 4 2 1 1 2 4 5 6
clang++ remove3.cpp -std=c++2a -Wall
1 2 3 4 5 6 7 8 9
number of removed elements: 1
1 2 4 5 6 7 8 9
g++ remove3.cpp -std=c++2a -Wall
1 2 3 4 5 6 7 8 9
number of removed elements: 1
1 2 4 5 6 7 8 9
clang++ remove4.cpp -std=c++2a -Wall
g++ remove4.cpp -std=c++2a -Wall
clang++ reviter1.cpp -std=c++2a -Wall
9 8 7 6 5 4 3 2 1
g++ reviter1.cpp -std=c++2a -Wall
9 8 7 6 5 4 3 2 1
clang++ set1.cpp -std=c++2a -Wall
1 2 3 4 5 6
g++ set1.cpp -std=c++2a -Wall
1 2 3 4 5 6
clang++ sort1.cpp -std=c++2a -Wall
deque before sort():
[nicolai josuttis]
[ulli josuttis]
[anica josuttis]
[lucas josuttis]
[lucas otto]
[lucas arm]
[anica holle]
deque after sort():
[lucas arm]
[anica holle]
[anica josuttis]
[lucas josuttis]
[nicolai josuttis]
[ulli josuttis]
[lucas otto]
g++ sort1.cpp -std=c++2a -Wall
deque before sort():
[nicolai josuttis]
[ulli josuttis]
[anica josuttis]
[lucas josuttis]
[lucas otto]
[lucas arm]
[anica holle]
deque after sort():
[lucas arm]
[anica holle]
[anica josuttis]
[lucas josuttis]
[nicolai josuttis]
[ulli josuttis]
[lucas otto]
clang++ sort2.cpp -std=c++2a -Wall
Undefined symbols for architecture x86_64:
"Person::lastname() const", referenced from:
main::$_0::operator()(Person const&, Person const&) const in sort2-373a67.o
"Person::firstname() const", referenced from:
main::$_0::operator()(Person const&, Person const&) const in sort2-373a67.o
ld: symbol(s) not found for architecture x86_64
clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)
g++ sort2.cpp -std=c++2a -Wall
Undefined symbols for architecture x86_64:
"Person::lastname[abi:cxx11]() const", referenced from:
main::{lambda(Person const&, Person const&)#1}::operator()(Person const&, Person const&) const in ccVuy9hX.o
"Person::firstname[abi:cxx11]() const", referenced from:
main::{lambda(Person const&, Person const&)#1}::operator()(Person const&, Person const&) const in ccVuy9hX.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
clang++ transform1.cpp -std=c++2a -Wall
initialized: 1 2 3 4 5 6 7 8 9
squared: 1 4 9 16 25 36 49 64 81
g++ transform1.cpp -std=c++2a -Wall
initialized: 1 2 3 4 5 6 7 8 9
squared: 1 4 9 16 25 36 49 64 81
clang++ unordmap1.cpp -std=c++2a -Wall
struppi: 138.533
tim: 98.01
g++ unordmap1.cpp -std=c++2a -Wall
struppi: 138.533
tim: 98.01
clang++ unordmultiset1.cpp -std=c++2a -Wall
Toronto Chicago Paris Hanover Frankfurt Frankfurt Braunschweig New York
London Toronto Chicago New York Paris Hanover Hanover Frankfurt Frankfurt Munich Braunschweig Braunschweig
g++ unordmultiset1.cpp -std=c++2a -Wall
Paris Toronto Chicago New York Frankfurt Frankfurt Hanover Braunschweig
Munich London Frankfurt Frankfurt New York Braunschweig Braunschweig Chicago Toronto Hanover Hanover Paris
clang++ unordmultiset2.cpp -std=c++2a -Wall
19 17 13 7 5 27 1 1 23 11 3
25 19 17 13 7 5 27 1 1 23 11 3
g++ unordmultiset2.cpp -std=c++2a -Wall
23 19 17 13 11 7 5 3 27 1 1
25 23 19 17 13 11 7 5 3 27 1 1
clang++ vector1.cpp -std=c++2a -Wall
1 2 3 4 5 6
g++ vector1.cpp -std=c++2a -Wall
vector1.cpp: In function 'int main()':
vector1.cpp:25:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
for (int i=0; i<coll.size(); ++i) {
~^~~~~~~~~~~~
1 2 3 4 5 6
検討事項(agenda)
- コンパイルエラーをなくす修正方法
- 役に立つまたは意味のあるその他の出力
参考資料(reference)
###プログラミング言語教育のXYZ
https://qiita.com/kaizen_nagoya/items/1950c5810fb5c0b07be4
プログラミング言語教育のXYZ(youtube)
https://www.youtube.com/watch?v=He1_tg4px-w&t=486s
###Autosar Guidelines C++14
Autosar Guidelines C++14 example code compile list(1-169)
https://qiita.com/kaizen_nagoya/items/8ccbf6675c3494d57a76
###C++N4741 2018
Working Draft, Standard for Programming Language C++
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/n4741.pdf
C++N4741, 2018 Standard Working Draft on ISO/IEC 14882 sample code compile list
https://qiita.com/kaizen_nagoya/items/3294c014044550896010
###C++N4606 2016
Working Draft, Standard for Programming Language C++
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/n4606.pdf
C++N4606, 2016符号断片編纂一覧(example code compile list)
Working Draft 2016, ISO/IEC 14882(1)
https://qiita.com/kaizen_nagoya/items/df5d62c35bd6ed1c3d43/
### CEDD(Compile Error Driven Design)
初めての CEDD(Compile Error Driven Design) 8回直してコンパイル。
https://qiita.com/kaizen_nagoya/items/9494236aa1753f3fd1e1
コンパイルエラーを記録するとよい理由7つ
https://qiita.com/kaizen_nagoya/items/85c0e92b206883140e89
docker gnu(gcc/g++) and llvm(clang/clang++)
https://qiita.com/drafts/059874ea39c4de64c0f7
[C][C++]の国際規格案の例題をコンパイルするときの課題7つ。
https://qiita.com/kaizen_nagoya/items/5f4b155030259497c4de
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.10 初稿 20180616
ver. 0.11 まとめURL追記 20180625
ver. 0.03 URL追記 20230214
最後までおよみいただきありがとうございました。
いいね 💚、フォローをお願いします。
Thank you very much for reading to the last sentence.
Please press the like icon 💚 and follow me for your happy life.