C++11
g++
clang++

The C++ Standard Library: clang++とg++でコンパイルしてみた(13)util

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)


util


util

clang++ ./util/chrono1.cpp -std=c++2a -Wall

epoch: Thu Jan 1 09:00:00 1970
now: Sun Jun 17 07:35:32 2018
min: Mon Dec 22 05:18:05 -290308
max: Sun Jan 10 13:00:54 294247
g++ ./util/chrono1.cpp -std=c++2a -Wall
epoch: Thu Jan 1 09:00:00 1970
now: Sun Jun 17 07:35:32 2018
min: Tue Sep 21 09:31:43 1677
max: Sat Apr 12 08:47:16 2262
clang++ ./util/chrono2.cpp -std=c++2a -Wall
epoch: Thu Jan 1 09:00:00 1970
later: Sat Jan 3 08:55:00 1970
diff: 2875 minute(s)
diff: 1 day(s)
-1 year: Fri Jan 3 08:55:00 1969
-50 years: Thu Jan 16 08:55:00 1919
-50 years: Wed Jan 27 09:13:59 1869
g++ ./util/chrono2.cpp -std=c++2a -Wall
epoch: Thu Jan 1 09:00:00 1970
later: Sat Jan 3 08:55:00 1970
diff: 2875 minute(s)
diff: 1 day(s)
-1 year: Fri Jan 3 08:55:00 1969
-50 years: Thu Jan 16 08:55:00 1919
-50 years: Wed Jan 27 09:13:59 1869
clang++ ./util/clock1.cpp -std=c++2a -Wall
system_clock:
- precision: 0.001000 milliseconds
- is_steady: false

high_resolution_clock:
- precision: 0.000001 milliseconds
- is_steady: true

steady_clock:
- precision: 0.000001 milliseconds
- is_steady: true
g++ ./util/clock1.cpp -std=c++2a -Wall
system_clock:
- precision: 0.000001 milliseconds
- is_steady: false

high_resolution_clock:
- precision: 0.000001 milliseconds
- is_steady: false

steady_clock:
- precision: 0.000001 milliseconds
- is_steady: true
clang++ ./util/enableshared1.cpp -std=c++2a -Wall
nico's family exists
- nico is shared 1 times
- name of 1st kid of nico's mom: nico
delete nico
delete nico's dad
delete nico's mom
jim's family exists
delete jim
delete jim's dad
delete jim's mom
g++ ./util/enableshared1.cpp -std=c++2a -Wall
nico's family exists
- nico is shared 1 times
- name of 1st kid of nico's mom: nico
delete nico
delete nico's dad
delete nico's mom
jim's family exists
delete jim
delete jim's dad
delete jim's mom
clang++ ./util/limits1.cpp -std=c++2a -Wall
max(short): 32767
max(int): 2147483647
max(long): 9223372036854775807

max(float): 3.40282e+38
max(double): 1.79769e+308
max(long double): 1.18973e+4932

is_signed(char): true

is_specialized(string): false
g++ ./util/limits1.cpp -std=c++2a -Wall
max(short): 32767
max(int): 2147483647
max(long): 9223372036854775807

max(float): 3.40282e+38
max(double): 1.79769e+308
max(long double): 1.18973e+4932

is_signed(char): true

is_specialized(string): false
clang++ ./util/minmax1.cpp -std=c++2a -Wall
./util/minmax1.cpp:29:10: warning: unused variable 'pmax' [-Wunused-variable]
int* pmax = std::max (px, py, int_ptr_less);
^
./util/minmax1.cpp:32:26: warning: unused variable 'extremes' [-Wunused-variable]
std::pair<int*,int*> extremes = std::minmax ({px, py, pz},
^
2 warnings generated.
g++ ./util/minmax1.cpp -std=c++2a -Wall
./util/minmax1.cpp: In function 'int main()':
./util/minmax1.cpp:29:10: warning: unused variable 'pmax' [-Wunused-variable]
int* pmax = std::max (px, py, int_ptr_less);
^~~~
./util/minmax1.cpp:32:26: warning: variable 'extremes' set but not used [-Wunused-but-set-variable]
std::pair<int*,int*> extremes = std::minmax ({px, py, pz},
^~~~~~~~
clang++ ./util/pair1.cpp -std=c++2a -Wall
Foo::Foo(tuple)
Foo::Foo(args...)
g++ ./util/pair1.cpp -std=c++2a -Wall
Foo::Foo(tuple)
Foo::Foo(args...)
clang++ ./util/ratio1.cpp -std=c++2a -Wall
5/3
5/3
1/1
0/1
-7/3
g++ ./util/ratio1.cpp -std=c++2a -Wall
5/3
5/3
1/1
0/1
-7/3
clang++ ./util/sharedptr1.cpp -std=c++2a -Wall
Jutta Jutta Nico Jutta Nico
Jutta Jutta Nicolai Jutta Nicolai
use_count: 4
g++ ./util/sharedptr1.cpp -std=c++2a -Wall
Jutta Jutta Nico Jutta Nico
Jutta Jutta Nicolai Jutta Nicolai
use_count: 4
clang++ ./util/sharedptr2.cpp -std=c++2a -Wall
g++ ./util/sharedptr2.cpp -std=c++2a -Wall
clang++ ./util/sharedptr3.cpp -std=c++2a -Wall
<return>
unlink /tmp1234
g++ ./util/sharedptr3.cpp -std=c++2a -Wall
<return>
unlink /tmp1234


$ ../cga.sh util2

clang++ timepoint1.cpp -std=c++2a -Wall
Fri Jan 1 00:00:00 2010
Mon May 23 13:44:00 2011
g++ timepoint1.cpp -std=c++2a -Wall
Fri Jan 1 00:00:00 2010
Mon May 23 13:44:00 2011
clang++ tuple1.cpp -std=c++2a -Wall
41 6.3 nico
g++ tuple1.cpp -std=c++2a -Wall
41 6.3 nico
clang++ tuple2.cpp -std=c++2a -Wall
io: [77,1.1,more light]
g++ tuple2.cpp -std=c++2a -Wall
io: [77,1.1,more light]
clang++ uniqueptr1.cpp -std=c++2a -Wall
process .
process ..
process ratio1.cpp
process tuple2.cpp
process pair1.cpp
process tuple1.cpp
process util
process enableshared1.cpp
process minmax1.cpp
process uniqueptr1.cpp.exe
process limits1.cpp
process uniqueptr1.cpp
process timepoint1.cpp
process clock.hpp
process sharedptr2.cpp
process weakptr2.cpp
process sharedptr3.cpp
process clock1.cpp
process sharedptr1.cpp
process weakptr1.cpp
process printtuple.hpp
process util2
process chrono1.cpp
process exception.hpp
process chrono2.cpp
process timepoint.hpp
g++ uniqueptr1.cpp -std=c++2a -Wall
process .
process ..
process ratio1.cpp
process tuple2.cpp
process pair1.cpp
process tuple1.cpp
process util
process enableshared1.cpp
process minmax1.cpp
process uniqueptr1.cpp.exe
process limits1.cpp
process uniqueptr1.cpp
process timepoint1.cpp
process clock.hpp
process sharedptr2.cpp
process weakptr2.cpp
process sharedptr3.cpp
process clock1.cpp
process sharedptr1.cpp
process weakptr1.cpp
process printtuple.hpp
process util2
process chrono1.cpp
process exception.hpp
process chrono2.cpp
process timepoint.hpp
clang++ weakptr1.cpp -std=c++2a -Wall
nico's family exists
- nico is shared 3 times
- name of 1st kid of nico's mom: nico
jim's family exists
g++ weakptr1.cpp -std=c++2a -Wall
nico's family exists
- nico is shared 3 times
- name of 1st kid of nico's mom: nico
jim's family exists
clang++ weakptr2.cpp -std=c++2a -Wall
nico's family exists
- nico is shared 1 times
- name of 1st kid of nico's mom: nico
delete nico
delete nico's dad
delete nico's mom
jim's family exists
delete jim
delete jim's dad
delete jim's mom
g++ weakptr2.cpp -std=c++2a -Wall
nico's family exists
- nico is shared 1 times
- name of 1st kid of nico's mom: nico
delete nico
delete nico's dad
delete nico's mom
jim's family exists
delete jim
delete jim's dad
delete jim's mom


検討事項(agenda)

1) コンパイルエラーをなくす修正方法

2) 役に立つまたは意味のあるその他の出力


参考資料(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