はじめに(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.
19.6.4.1 Overview [stacktrace.basic.overview] C++N4910:2022 (413) p573c.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 = "19.6.4.1 Overview [stacktrace.basic.overview] C++N4910:2022 (413) p573c.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
namespace std {
template<class Allocator>
class basic_stacktrace {
public:
using value_type = stacktrace_entry;
using const_reference = const value_type&;
using reference = value_type&;
using const_iterator = implementation_defined ;
using iterator = const_iterator;
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
using difference_type = implementation_defined;
using size_type = implementation_defined;
using allocator_type = Allocator;
// 19.6.4.2, creation and assignment
static basic_stacktrace current(const allocator_type& alloc = allocator_type()) noexcept;
static basic_stacktrace current(size_type skip,
const allocator_type& alloc = allocator_type()) noexcept;
static basic_stacktrace current(size_type skip, size_type max_depth,
// see 19.6.4.3
const allocator_type& alloc = allocator_type()) noexcept;
// - only move, assignment, swap, and operations defined for const-qualified sequence containers are supported and,
// - the semantics of comparison functions are different from those required for a container.
basic_stacktrace() noexcept(is_nothrow_default_constructible_v<allocator_type>);
explicit basic_stacktrace(const allocator_type& alloc) noexcept;
basic_stacktrace(const basic_stacktrace& other);
basic_stacktrace(basic_stacktrace&& other) noexcept;
basic_stacktrace(const basic_stacktrace& other, const allocator_type& alloc);
basic_stacktrace(basic_stacktrace&& other, const allocator_type& alloc);
basic_stacktrace& operator=(const basic_stacktrace& other);
basic_stacktrace& operator=(basic_stacktrace&& other)
noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
allocator_traits<Allocator>::is_always_equal::value);
~basic_stacktrace(); // 19.6.4.3, observers
allocator_type get_allocator() const noexcept;
const_iterator begin() const noexcept;
const_iterator end() const noexcept;
const_reverse_iterator rbegin() const noexcept;
const_reverse_iterator rend() const noexcept;
const_iterator cbegin() const noexcept;
const_iterator cend() const noexcept;
const_reverse_iterator crbegin() const noexcept;
const_reverse_iterator crend() const noexcept;
[[nodiscard]] bool empty() const noexcept;
size_type size() const noexcept;
size_type max_size() const noexcept;
const_reference operator[](size_type) const;
const_reference at(size_type) const;
// 19.6.4.4, comparisons
template<class Allocator2>
friend bool operator==(const basic_stacktrace& x,
const basic_stacktrace<Allocator2>& y) noexcept;
template<class Allocator2>
friend strong_ordering operator<=>(const basic_stacktrace& x,
const basic_stacktrace<Allocator2>& y) noexcept;
// 19.6.4.5, modifiers
void swap(basic_stacktrace& other)
noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
allocator_traits<Allocator>::is_always_equal::value);
private:
vector<value_type, allocator_type> frames_; // exposition only
};
}
int main() {
cout << n4910 << endl;
return EXIT_SUCCESS;
}
編纂・実行結果(compile and go)
$ clang++ p573c.cpp -std=c++03 -o p573cl -I. -Wall
In file included from p573c.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 \
^
p573c.cpp:30:20: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using value_type = stacktrace_entry;
^
p573c.cpp:30:20: error: unknown type name 'stacktrace_entry'
p573c.cpp:31:25: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using const_reference = const value_type&;
^
p573c.cpp:31:31: error: unknown type name 'value_type'; did you mean '_Bit_const_iterator::value_type'?
using const_reference = const value_type&;
^~~~~~~~~~
_Bit_const_iterator::value_type
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_iterator_base_types.h:132:26: note: '_Bit_const_iterator::value_type' declared here
typedef _Tp value_type;
^
p573c.cpp:32:19: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using reference = value_type&;
^
p573c.cpp:32:19: error: unknown type name 'value_type'; did you mean '_Bit_const_iterator::value_type'?
using reference = value_type&;
^~~~~~~~~~
_Bit_const_iterator::value_type
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_iterator_base_types.h:132:26: note: '_Bit_const_iterator::value_type' declared here
typedef _Tp value_type;
^
p573c.cpp:33:24: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using const_iterator = implementation_defined ;
^
p573c.cpp:33:24: error: unknown type name 'implementation_defined'
p573c.cpp:34:18: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using iterator = const_iterator;
^
p573c.cpp:34:18: error: unknown type name 'const_iterator'; did you mean '_Bit_const_iterator::const_iterator'?
using iterator = const_iterator;
^~~~~~~~~~~~~~
_Bit_const_iterator::const_iterator
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_bvector.h:332:34: note: '_Bit_const_iterator::const_iterator' declared here
typedef _Bit_const_iterator const_iterator;
^
p573c.cpp:35:26: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using reverse_iterator = std::reverse_iterator<iterator>;
^
p573c.cpp:36:32: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
^
p573c.cpp:36:54: error: unknown type name 'const_iterator'; did you mean '_Bit_const_iterator::const_iterator'?
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
^~~~~~~~~~~~~~
_Bit_const_iterator::const_iterator
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_bvector.h:332:34: note: '_Bit_const_iterator::const_iterator' declared here
typedef _Bit_const_iterator const_iterator;
^
p573c.cpp:37:25: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using difference_type = implementation_defined;
^
p573c.cpp:37:25: error: unknown type name 'implementation_defined'
p573c.cpp:38:19: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using size_type = implementation_defined;
^
p573c.cpp:38:19: error: unknown type name 'implementation_defined'
p573c.cpp:39:24: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using allocator_type = Allocator;
^
p573c.cpp:41:80: error: expected ';' at end of declaration list
static basic_stacktrace current(const allocator_type& alloc = allocator_type()) noexcept;
^
;
p573c.cpp:42:33: error: unknown type name 'size_type'
static basic_stacktrace current(size_type skip,
^
p573c.cpp:43:80: error: expected ';' at end of declaration list
const allocator_type& alloc = allocator_type()) noexcept;
^
;
p573c.cpp:44:33: error: unknown type name 'size_type'
static basic_stacktrace current(size_type skip, size_type max_depth,
^
p573c.cpp:44:49: error: unknown type name 'size_type'
static basic_stacktrace current(size_type skip, size_type max_depth,
^
p573c.cpp:46:48: error: expected ';' at end of declaration list
const allocator_type& alloc = allocator_type()) noexcept;
^
;
p573c.cpp:49:28: error: expected ';' at end of declaration list
basic_stacktrace() noexcept(is_nothrow_default_constructible_v<allocator_type>);
^
;
p573c.cpp:50:64: error: expected ';' at end of declaration list
explicit basic_stacktrace(const allocator_type& alloc) noexcept;
^
;
p573c.cpp:52:43: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
basic_stacktrace(basic_stacktrace&& other) noexcept;
^
p573c.cpp:52:52: error: expected ';' at end of declaration list
basic_stacktrace(basic_stacktrace&& other) noexcept;
^
;
p573c.cpp:54:43: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
basic_stacktrace(basic_stacktrace&& other, const allocator_type& alloc);
^
p573c.cpp:56:54: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
basic_stacktrace& operator=(basic_stacktrace&& other)
^
p573c.cpp:56:63: error: expected ';' at end of declaration list
basic_stacktrace& operator=(basic_stacktrace&& other)
^
;
fatal error: too many errors emitted, stopping now [-ferror-limit=]
13 warnings and 20 errors generated.
rm: cannot remove 'p573cl': No such file or directory
$ clang++ p573c.cpp -std=c++2b -o p573cl -I. -Wall
p573c.cpp:30:20: error: unknown type name 'stacktrace_entry'
using value_type = stacktrace_entry;
^
p573c.cpp:31:31: error: unknown type name 'value_type'; did you mean '_Bit_const_iterator::value_type'?
using const_reference = const value_type&;
^~~~~~~~~~
_Bit_const_iterator::value_type
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_iterator_base_types.h:132:26: note: '_Bit_const_iterator::value_type' declared here
typedef _Tp value_type;
^
p573c.cpp:32:19: error: unknown type name 'value_type'; did you mean '_Bit_const_iterator::value_type'?
using reference = value_type&;
^~~~~~~~~~
_Bit_const_iterator::value_type
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_iterator_base_types.h:132:26: note: '_Bit_const_iterator::value_type' declared here
typedef _Tp value_type;
^
p573c.cpp:33:24: error: unknown type name 'implementation_defined'
using const_iterator = implementation_defined ;
^
p573c.cpp:34:18: error: unknown type name 'const_iterator'; did you mean '_Bit_const_iterator::const_iterator'?
using iterator = const_iterator;
^~~~~~~~~~~~~~
_Bit_const_iterator::const_iterator
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_bvector.h:332:34: note: '_Bit_const_iterator::const_iterator' declared here
typedef _Bit_const_iterator const_iterator;
^
p573c.cpp:36:54: error: unknown type name 'const_iterator'; did you mean '_Bit_const_iterator::const_iterator'?
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
^~~~~~~~~~~~~~
_Bit_const_iterator::const_iterator
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_bvector.h:332:34: note: '_Bit_const_iterator::const_iterator' declared here
typedef _Bit_const_iterator const_iterator;
^
p573c.cpp:37:25: error: unknown type name 'implementation_defined'
using difference_type = implementation_defined;
^
p573c.cpp:38:19: error: unknown type name 'implementation_defined'
using size_type = implementation_defined;
^
p573c.cpp:42:33: error: unknown type name 'size_type'
static basic_stacktrace current(size_type skip,
^
p573c.cpp:44:33: error: unknown type name 'size_type'
static basic_stacktrace current(size_type skip, size_type max_depth,
^
p573c.cpp:44:49: error: unknown type name 'size_type'
static basic_stacktrace current(size_type skip, size_type max_depth,
^
p573c.cpp:61:10: error: unknown type name 'const_iterator'; did you mean '_Bit_const_iterator::const_iterator'?
const_iterator begin() const noexcept;
^~~~~~~~~~~~~~
_Bit_const_iterator::const_iterator
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_bvector.h:332:34: note: '_Bit_const_iterator::const_iterator' declared here
typedef _Bit_const_iterator const_iterator;
^
p573c.cpp:62:10: error: unknown type name 'const_iterator'; did you mean '_Bit_const_iterator::const_iterator'?
const_iterator end() const noexcept;
^~~~~~~~~~~~~~
_Bit_const_iterator::const_iterator
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_bvector.h:332:34: note: '_Bit_const_iterator::const_iterator' declared here
typedef _Bit_const_iterator const_iterator;
^
p573c.cpp:65:10: error: unknown type name 'const_iterator'; did you mean '_Bit_const_iterator::const_iterator'?
const_iterator cbegin() const noexcept;
^~~~~~~~~~~~~~
_Bit_const_iterator::const_iterator
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_bvector.h:332:34: note: '_Bit_const_iterator::const_iterator' declared here
typedef _Bit_const_iterator const_iterator;
^
p573c.cpp:66:10: error: unknown type name 'const_iterator'; did you mean '_Bit_const_iterator::const_iterator'?
const_iterator cend() const noexcept;
^~~~~~~~~~~~~~
_Bit_const_iterator::const_iterator
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_bvector.h:332:34: note: '_Bit_const_iterator::const_iterator' declared here
typedef _Bit_const_iterator const_iterator;
^
p573c.cpp:70:10: error: unknown type name 'size_type'
size_type size() const noexcept;
^
p573c.cpp:71:10: error: unknown type name 'size_type'
size_type max_size() const noexcept;
^
p573c.cpp:72:37: error: unknown type name 'size_type'
const_reference operator[](size_type) const;
^
p573c.cpp:73:29: error: unknown type name 'size_type'
const_reference at(size_type) const;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
$ g++ p573c.cpp -std=c++03 -o p573cg -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
from p573c.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 \
| ^~~~~
p573c.cpp:41:81: warning: identifier 'noexcept' is a keyword in C++11 [-Wc++11-compat]
41 | static basic_stacktrace current(const allocator_type& alloc = allocator_type()) noexcept;
| ^~~~~~~~
p573c.cpp:30:7: error: expected nested-name-specifier before 'value_type'
30 | using value_type = stacktrace_entry;
| ^~~~~~~~~~
p573c.cpp:31:7: error: expected nested-name-specifier before 'const_reference'
31 | using const_reference = const value_type&;
| ^~~~~~~~~~~~~~~
p573c.cpp:32:7: error: expected nested-name-specifier before 'reference'
32 | using reference = value_type&;
| ^~~~~~~~~
p573c.cpp:33:7: error: expected nested-name-specifier before 'const_iterator'
33 | using const_iterator = implementation_defined ;
| ^~~~~~~~~~~~~~
p573c.cpp:34:7: error: expected nested-name-specifier before 'iterator'
34 | using iterator = const_iterator;
| ^~~~~~~~
p573c.cpp:35:7: error: expected nested-name-specifier before 'reverse_iterator'
35 | using reverse_iterator = std::reverse_iterator<iterator>;
| ^~~~~~~~~~~~~~~~
p573c.cpp:36:7: error: expected nested-name-specifier before 'const_reverse_iterator'
36 | using const_reverse_iterator = std::reverse_iterator<const_iterator>;
| ^~~~~~~~~~~~~~~~~~~~~~
p573c.cpp:37:7: error: expected nested-name-specifier before 'difference_type'
37 | using difference_type = implementation_defined;
| ^~~~~~~~~~~~~~~
p573c.cpp:38:7: error: expected nested-name-specifier before 'size_type'
38 | using size_type = implementation_defined;
| ^~~~~~~~~
p573c.cpp:39:7: error: expected nested-name-specifier before 'allocator_type'
39 | using allocator_type = Allocator;
| ^~~~~~~~~~~~~~
p573c.cpp:41:39: error: 'allocator_type' does not name a type; did you mean 'allocator'?
41 | static basic_stacktrace current(const allocator_type& alloc = allocator_type()) noexcept;
| ^~~~~~~~~~~~~~
| allocator
p573c.cpp:41:79: error: expected ';' at end of member declaration
41 | static basic_stacktrace current(const allocator_type& alloc = allocator_type()) noexcept;
| ^
| ;
p573c.cpp:41:81: error: 'noexcept' does not name a type
41 | static basic_stacktrace current(const allocator_type& alloc = allocator_type()) noexcept;
| ^~~~~~~~
p573c.cpp:41:81: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p573c.cpp:42:33: error: 'size_type' has not been declared
42 | static basic_stacktrace current(size_type skip,
| ^~~~~~~~~
p573c.cpp:43:39: error: 'allocator_type' does not name a type; did you mean 'allocator'?
43 | const allocator_type& alloc = allocator_type()) noexcept;
| ^~~~~~~~~~~~~~
| allocator
p573c.cpp:43:79: error: expected ';' at end of member declaration
43 | const allocator_type& alloc = allocator_type()) noexcept;
| ^
| ;
p573c.cpp:43:81: error: 'noexcept' does not name a type
43 | const allocator_type& alloc = allocator_type()) noexcept;
| ^~~~~~~~
p573c.cpp:43:81: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p573c.cpp:44:33: error: 'size_type' has not been declared
44 | static basic_stacktrace current(size_type skip, size_type max_depth,
| ^~~~~~~~~
p573c.cpp:44:49: error: 'size_type' has not been declared
44 | static basic_stacktrace current(size_type skip, size_type max_depth,
| ^~~~~~~~~
p573c.cpp:46:7: error: 'allocator_type' does not name a type; did you mean 'allocator'?
46 | const allocator_type& alloc = allocator_type()) noexcept;
| ^~~~~~~~~~~~~~
| allocator
p573c.cpp:46:47: error: expected ';' at end of member declaration
46 | const allocator_type& alloc = allocator_type()) noexcept;
| ^
| ;
p573c.cpp:46:49: error: 'noexcept' does not name a type
46 | const allocator_type& alloc = allocator_type()) noexcept;
| ^~~~~~~~
p573c.cpp:46:49: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p573c.cpp:49:27: error: expected ';' at end of member declaration
49 | basic_stacktrace() noexcept(is_nothrow_default_constructible_v<allocator_type>);
| ^
| ;
p573c.cpp:49:38: error: 'is_nothrow_default_constructible_v' has not been declared
49 | basic_stacktrace() noexcept(is_nothrow_default_constructible_v<allocator_type>);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
p573c.cpp:49:72: error: expected ',' or '...' before '<' token
49 | basic_stacktrace() noexcept(is_nothrow_default_constructible_v<allocator_type>);
| ^
p573c.cpp:49:29: error: ISO C++ forbids declaration of 'noexcept' with no type [-fpermissive]
49 | basic_stacktrace() noexcept(is_nothrow_default_constructible_v<allocator_type>);
| ^~~~~~~~
p573c.cpp:50:42: error: 'allocator_type' does not name a type; did you mean 'allocator'?
50 | explicit basic_stacktrace(const allocator_type& alloc) noexcept;
| ^~~~~~~~~~~~~~
| allocator
p573c.cpp:50:63: error: expected ';' at end of member declaration
50 | explicit basic_stacktrace(const allocator_type& alloc) noexcept;
| ^
| ;
p573c.cpp:50:65: error: 'noexcept' does not name a type
50 | explicit basic_stacktrace(const allocator_type& alloc) noexcept;
| ^~~~~~~~
p573c.cpp:50:65: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p573c.cpp:52:43: error: expected ',' or '...' before '&&' token
52 | basic_stacktrace(basic_stacktrace&& other) noexcept;
| ^~
p573c.cpp:52:10: error: invalid constructor; you probably meant 'std::basic_stacktrace<Allocator> (const std::basic_stacktrace<Allocator>&)'
52 | basic_stacktrace(basic_stacktrace&& other) noexcept;
| ^~~~~~~~~~~~~~~~
p573c.cpp:52:51: error: expected ';' at end of member declaration
52 | basic_stacktrace(basic_stacktrace&& other) noexcept;
| ^
| ;
p573c.cpp:52:53: error: 'noexcept' does not name a type
52 | basic_stacktrace(basic_stacktrace&& other) noexcept;
| ^~~~~~~~
p573c.cpp:52:53: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p573c.cpp:53:64: error: 'allocator_type' does not name a type; did you mean 'allocator'?
53 | basic_stacktrace(const basic_stacktrace& other, const allocator_type& alloc);
| ^~~~~~~~~~~~~~
| allocator
p573c.cpp:54:43: error: expected ',' or '...' before '&&' token
54 | basic_stacktrace(basic_stacktrace&& other, const allocator_type& alloc);
| ^~
p573c.cpp:54:10: error: invalid constructor; you probably meant 'std::basic_stacktrace<Allocator> (const std::basic_stacktrace<Allocator>&)'
54 | basic_stacktrace(basic_stacktrace&& other, const allocator_type& alloc);
| ^~~~~~~~~~~~~~~~
p573c.cpp:56:54: error: expected ',' or '...' before '&&' token
56 | basic_stacktrace& operator=(basic_stacktrace&& other)
| ^~
p573c.cpp:56:62: error: expected ';' at end of member declaration
56 | basic_stacktrace& operator=(basic_stacktrace&& other)
| ^
| ;
p573c.cpp:57:21: error: 'allocator_traits' has not been declared
57 | noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
| ^~~~~~~~~~~~~~~~
p573c.cpp:57:37: error: expected ',' or '...' before '<' token
57 | noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
| ^
p573c.cpp:57:12: error: ISO C++ forbids declaration of 'noexcept' with no type [-fpermissive]
57 | noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
| ^~~~~~~~
p573c.cpp:57:12: error: 'int std::basic_stacktrace<Allocator>::noexcept(int)' cannot be overloaded with 'int std::basic_stacktrace<Allocator>::noexcept(int)'
p573c.cpp:49:29: note: previous declaration 'int std::basic_stacktrace<Allocator>::noexcept(int)'
49 | basic_stacktrace() noexcept(is_nothrow_default_constructible_v<allocator_type>);
| ^~~~~~~~
p573c.cpp:60:10: error: 'allocator_type' does not name a type; did you mean 'allocator'?
60 | allocator_type get_allocator() const noexcept;
| ^~~~~~~~~~~~~~
| allocator
p573c.cpp:61:10: error: 'const_iterator' does not name a type; did you mean 'insert_iterator'?
61 | const_iterator begin() const noexcept;
| ^~~~~~~~~~~~~~
| insert_iterator
p573c.cpp:62:10: error: 'const_iterator' does not name a type; did you mean 'insert_iterator'?
62 | const_iterator end() const noexcept;
| ^~~~~~~~~~~~~~
| insert_iterator
p573c.cpp:63:10: error: 'const_reverse_iterator' does not name a type; did you mean 'reverse_iterator'?
63 | const_reverse_iterator rbegin() const noexcept;
| ^~~~~~~~~~~~~~~~~~~~~~
| reverse_iterator
p573c.cpp:64:10: error: 'const_reverse_iterator' does not name a type; did you mean 'reverse_iterator'?
64 | const_reverse_iterator rend() const noexcept;
| ^~~~~~~~~~~~~~~~~~~~~~
| reverse_iterator
p573c.cpp:65:10: error: 'const_iterator' does not name a type; did you mean 'insert_iterator'?
65 | const_iterator cbegin() const noexcept;
| ^~~~~~~~~~~~~~
| insert_iterator
p573c.cpp:66:10: error: 'const_iterator' does not name a type; did you mean 'insert_iterator'?
66 | const_iterator cend() const noexcept;
| ^~~~~~~~~~~~~~
| insert_iterator
p573c.cpp:67:10: error: 'const_reverse_iterator' does not name a type; did you mean 'reverse_iterator'?
67 | const_reverse_iterator crbegin() const noexcept;
| ^~~~~~~~~~~~~~~~~~~~~~
| reverse_iterator
p573c.cpp:68:10: error: 'const_reverse_iterator' does not name a type; did you mean 'reverse_iterator'?
68 | const_reverse_iterator crend() const noexcept;
| ^~~~~~~~~~~~~~~~~~~~~~
| reverse_iterator
p573c.cpp:69:10: error: expected unqualified-id before '[' token
69 | [[nodiscard]] bool empty() const noexcept;
| ^
p573c.cpp:70:10: error: 'size_type' does not name a type; did you mean 'size_t'?
70 | size_type size() const noexcept;
| ^~~~~~~~~
| size_t
p573c.cpp:71:10: error: 'size_type' does not name a type; did you mean 'size_t'?
71 | size_type max_size() const noexcept;
| ^~~~~~~~~
| size_t
p573c.cpp:72:10: error: 'const_reference' does not name a type
72 | const_reference operator[](size_type) const;
| ^~~~~~~~~~~~~~~
p573c.cpp:73:10: error: 'const_reference' does not name a type
73 | const_reference at(size_type) const;
| ^~~~~~~~~~~~~~~
p573c.cpp:77:72: error: expected initializer before 'noexcept'
77 | const basic_stacktrace<Allocator2>& y) noexcept;
| ^~~~~~~~
p573c.cpp:79:17: error: 'strong_ordering' does not name a type
79 | friend strong_ordering operator<=>(const basic_stacktrace& x,
| ^~~~~~~~~~~~~~~
p573c.cpp:82:34: error: expected ';' at end of member declaration
82 | void swap(basic_stacktrace& other)
| ^
| ;
p573c.cpp:83:21: error: 'allocator_traits' has not been declared
83 | noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
| ^~~~~~~~~~~~~~~~
p573c.cpp:83:37: error: expected ',' or '...' before '<' token
83 | noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
| ^
p573c.cpp:83:12: error: ISO C++ forbids declaration of 'noexcept' with no type [-fpermissive]
83 | noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
| ^~~~~~~~
p573c.cpp:83:12: error: 'int std::basic_stacktrace<Allocator>::noexcept(int)' cannot be overloaded with 'int std::basic_stacktrace<Allocator>::noexcept(int)'
p573c.cpp:49:29: note: previous declaration 'int std::basic_stacktrace<Allocator>::noexcept(int)'
49 | basic_stacktrace() noexcept(is_nothrow_default_constructible_v<allocator_type>);
| ^~~~~~~~
p573c.cpp:86:8: error: 'value_type' was not declared in this scope
86 | vector<value_type, allocator_type> frames_; // exposition only
| ^~~~~~~~~~
p573c.cpp:86:20: error: 'allocator_type' was not declared in this scope; did you mean 'allocator'?
86 | vector<value_type, allocator_type> frames_; // exposition only
| ^~~~~~~~~~~~~~
| allocator
p573c.cpp:86:34: error: template argument 1 is invalid
86 | vector<value_type, allocator_type> frames_; // exposition only
| ^
p573c.cpp:86:34: error: template argument 2 is invalid
p573c.cpp:41:63: error: there are no arguments to 'allocator_type' that depend on a template parameter, so a declaration of 'allocator_type' must be available [-fpermissive]
41 | static basic_stacktrace current(const allocator_type& alloc = allocator_type()) noexcept;
| ^~~~~~~~~~~~~~
p573c.cpp:41:63: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
p573c.cpp:43:63: error: there are no arguments to 'allocator_type' that depend on a template parameter, so a declaration of 'allocator_type' must be available [-fpermissive]
43 | const allocator_type& alloc = allocator_type()) noexcept;
| ^~~~~~~~~~~~~~
p573c.cpp:46:31: error: there are no arguments to 'allocator_type' that depend on a template parameter, so a declaration of 'allocator_type' must be available [-fpermissive]
46 | const allocator_type& alloc = allocator_type()) noexcept;
| ^~~~~~~~~~~~~~
rm: cannot remove 'p573cg': No such file or directory
$ g++ p573c.cpp -std=c++2b -o p573cg -I. -Wall
p573c.cpp:30:20: error: 'stacktrace_entry' does not name a type
30 | using value_type = stacktrace_entry;
| ^~~~~~~~~~~~~~~~
p573c.cpp:31:31: error: ISO C++ forbids declaration of 'type name' with no type [-fpermissive]
31 | using const_reference = const value_type&;
| ^~~~~~~~~~
p573c.cpp:31:30: error: expected ';' before 'value_type'
31 | using const_reference = const value_type&;
| ^~~~~~~~~~~
| ;
p573c.cpp:32:19: error: 'value_type' does not name a type; did you mean 'false_type'?
32 | using reference = value_type&;
| ^~~~~~~~~~
| false_type
p573c.cpp:33:24: error: 'implementation_defined' does not name a type
33 | using const_iterator = implementation_defined ;
| ^~~~~~~~~~~~~~~~~~~~~~
p573c.cpp:34:18: error: 'const_iterator' does not name a type; did you mean 'move_iterator'?
34 | using iterator = const_iterator;
| ^~~~~~~~~~~~~~
| move_iterator
p573c.cpp:35:48: warning: 'template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> struct std::iterator' is deprecated [-Wdeprecated-declarations]
35 | using reverse_iterator = std::reverse_iterator<iterator>;
| ^~~~~~~~
In file included from /usr/local/include/c++/12.1.0/bits/stl_construct.h:61,
from /usr/local/include/c++/12.1.0/bits/char_traits.h:46,
from /usr/local/include/c++/12.1.0/ios:40,
from /usr/local/include/c++/12.1.0/ostream:38,
from /usr/local/include/c++/12.1.0/iostream:39,
from p573c.cpp:10:
/usr/local/include/c++/12.1.0/bits/stl_iterator_base_types.h:127:34: note: declared here
127 | struct _GLIBCXX17_DEPRECATED iterator
| ^~~~~~~~
p573c.cpp:35:56: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Iterator> class std::reverse_iterator'
35 | using reverse_iterator = std::reverse_iterator<iterator>;
| ^
p573c.cpp:35:56: note: expected a type, got 'iterator'
p573c.cpp:35:31: error: '<expression error>' in namespace 'std' does not name a type
35 | using reverse_iterator = std::reverse_iterator<iterator>;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
p573c.cpp:36:54: error: 'const_iterator' was not declared in this scope; did you mean 'move_iterator'?
36 | using const_reverse_iterator = std::reverse_iterator<const_iterator>;
| ^~~~~~~~~~~~~~
| move_iterator
p573c.cpp:36:68: error: template argument 1 is invalid
36 | using const_reverse_iterator = std::reverse_iterator<const_iterator>;
| ^
p573c.cpp:36:37: error: '<expression error>' in namespace 'std' does not name a type
36 | using const_reverse_iterator = std::reverse_iterator<const_iterator>;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
p573c.cpp:37:25: error: 'implementation_defined' does not name a type
37 | using difference_type = implementation_defined;
| ^~~~~~~~~~~~~~~~~~~~~~
p573c.cpp:38:19: error: 'implementation_defined' does not name a type
38 | using size_type = implementation_defined;
| ^~~~~~~~~~~~~~~~~~~~~~
p573c.cpp:42:33: error: 'size_type' has not been declared
42 | static basic_stacktrace current(size_type skip,
| ^~~~~~~~~
p573c.cpp:44:33: error: 'size_type' has not been declared
44 | static basic_stacktrace current(size_type skip, size_type max_depth,
| ^~~~~~~~~
p573c.cpp:44:49: error: 'size_type' has not been declared
44 | static basic_stacktrace current(size_type skip, size_type max_depth,
| ^~~~~~~~~
p573c.cpp:61:10: error: 'const_iterator' does not name a type; did you mean 'move_iterator'?
61 | const_iterator begin() const noexcept;
| ^~~~~~~~~~~~~~
| move_iterator
p573c.cpp:62:10: error: 'const_iterator' does not name a type; did you mean 'move_iterator'?
62 | const_iterator end() const noexcept;
| ^~~~~~~~~~~~~~
| move_iterator
p573c.cpp:63:10: error: 'const_reverse_iterator' does not name a type; did you mean 'reverse_iterator'?
63 | const_reverse_iterator rbegin() const noexcept;
| ^~~~~~~~~~~~~~~~~~~~~~
| reverse_iterator
p573c.cpp:64:10: error: 'const_reverse_iterator' does not name a type; did you mean 'reverse_iterator'?
64 | const_reverse_iterator rend() const noexcept;
| ^~~~~~~~~~~~~~~~~~~~~~
| reverse_iterator
p573c.cpp:65:10: error: 'const_iterator' does not name a type; did you mean 'move_iterator'?
65 | const_iterator cbegin() const noexcept;
| ^~~~~~~~~~~~~~
| move_iterator
p573c.cpp:66:10: error: 'const_iterator' does not name a type; did you mean 'move_iterator'?
66 | const_iterator cend() const noexcept;
| ^~~~~~~~~~~~~~
| move_iterator
p573c.cpp:67:10: error: 'const_reverse_iterator' does not name a type; did you mean 'reverse_iterator'?
67 | const_reverse_iterator crbegin() const noexcept;
| ^~~~~~~~~~~~~~~~~~~~~~
| reverse_iterator
p573c.cpp:68:10: error: 'const_reverse_iterator' does not name a type; did you mean 'reverse_iterator'?
68 | const_reverse_iterator crend() const noexcept;
| ^~~~~~~~~~~~~~~~~~~~~~
| reverse_iterator
p573c.cpp:70:10: error: 'size_type' does not name a type; did you mean 'true_type'?
70 | size_type size() const noexcept;
| ^~~~~~~~~
| true_type
p573c.cpp:71:10: error: 'size_type' does not name a type; did you mean 'true_type'?
71 | size_type max_size() const noexcept;
| ^~~~~~~~~
| true_type
p573c.cpp:72:10: error: 'const_reference' does not name a type; did you mean 'is_reference'?
72 | const_reference operator[](size_type) const;
| ^~~~~~~~~~~~~~~
| is_reference
p573c.cpp:73:10: error: 'const_reference' does not name a type; did you mean 'is_reference'?
73 | const_reference at(size_type) const;
| ^~~~~~~~~~~~~~~
| is_reference
p573c.cpp:86:8: error: 'value_type' was not declared in this scope; did you mean 'false_type'?
86 | vector<value_type, allocator_type> frames_; // exposition only
| ^~~~~~~~~~
| false_type
p573c.cpp:86:34: error: template argument 1 is invalid
86 | vector<value_type, allocator_type> frames_; // exposition only
| ^
検討事項(agenda)
コンパイルエラーを取るか、コンパイルエラーの理由を解説する。
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
参考資料(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 初稿 20220716