はじめに(Introduction)
C++N4606 Working Draft, Standard for Programming Language C++
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/#mailing2016-11
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/n4606.pdf
C++N4606は、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)との関係も調査中です。
何か、抜け漏れ、耳より情報がありましたらおしらせくださると幸いです。
作業方針(sequence)
1)コンパイルエラーを収集する。
2)コンパイルエラーをなくす方法を検討する。
コンパイルエラーになる例を示すだけが目的のコードは、コンパイルエラーをなくすのではなく、コンパイルエラーの種類を収集するだけにする。
文法を示すのが目的のコード場合に、コンパイルエラーをなくすのに手間がかかる場合は、順次作業します。
3)リンクエラーをなくす方法を検討する。
文法を示すのが目的のコード場合に、リンクエラーをなくすのに手間がかかる場合は、順次作業します。
4)意味のある出力を作る。
コンパイル、リンクが通っても、意味のある出力を示そうとすると、コンパイル・リンクエラーが出て収拾できそうにない場合がある。順次作業します。
1)だけのものから4)まで進んだものと色々ある状態です。一歩でも前に進むご助言をお待ちしています。「検討事項」の欄に現状を記録するようにしています。
C++N4606符号断片編纂一覧(example code compile list)
C++N4606 Working Draft 2016, ISO/IEC 14882, C++ standard(1) Example code compile list
https://qiita.com/kaizen_nagoya/items/df5d62c35bd6ed1c3d43/
編纂器(Compiler)
clang++ --version
clang version 6.0.0 (tags/RELEASE_600/final)
Target: x86_64-apple-darwin17.4.0
g++-7 --version
g++-7 (Homebrew GCC 7.3.0_1) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
(278)C.4 C++ and ISO C++ 2014 [diff.cpp14]p1437
算譜(source code)
// C++N4606 Committee Draft, Standard for Programming Language C++
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/n4606.pdf
#define msg "C++N460(278)C.4 C++ and ISO C++ 2014 [diff.cpp14]p1437.cpp"
// Edited by Dr. Ogawa Kiyoshi. Compile procedure and results record.
#include <iostream>
#include <cstdlib>
using namespace std;
// C.4 C++ and ISO C++ 2014 [diff.cpp14]
// C.4.1 Clause 2: lexical conventions [diff.cpp14.lex]
#define F(a) b ## a
int b0p = F(0p+0); // ill-formed; equivalent to “int b0p = b0p + 0;” in C++ 2014
//C.4.3 Clause 7: declarations [diff.cpp14.dcl.dcl]
auto x1 {
1
}; // was std::initializer_list<int>, now int
//auto x2{1, 2}; // was std::initializer_list<int>, now ill-formed
//C.4.4 Clause 8: declarators [diff.cpp14.decl]
void g1() noexcept;
void g2();
template<class T> int f(T *, T *);
//int x = f(g1, g2); // ill-formed; previously well-formed
struct derived;
struct base {
friend struct derived;
private:
base();
};
struct derived : base {};
//derived d1{}; // Error. The code was well-formed before.
derived d2; // still OK
//C.4.5 Clause 12: special member functions [diff.cpp14.special]
struct A {
template<typename T> A(T, typename T::type = 0);
A(int);
};
struct B : A {
using A::A;
B(int);
};
B b(42L); // now calls B(int), used to call B<long>(long),
// which called A(int) due to substitution failure
// in A<long>(long).
//C.4.6 Clause 14: templates [diff.cpp14.temp]
template <int N> struct A2;/// change A to A2
template <typename T, T N> int foo(A2<N> *) = delete;
void foo(void *);
void bar(A2<0> *p) {
foo(p); // ill-formed; previously well-formed
}
//C.4.9 Clause 21: strings library [diff.cpp14.string]
int f(char *) = delete;
int f(const char *);
string s;
int x = f(s.data()); // ill-formed; previously well-formed
// C.4.10 Clause 23: containers library [diff.cpp14.containers]
#include <set>
struct compare
{
bool operator()(int a, int b)
{
return a < b;
}
};
int main() {
const std::set<int, compare> s;
s.find(0);
std::cout<< msg << std::endl;
return EXIT_SUCCESS;
}`
##編纂・実行結果(compile and go)
```shell_session:cppall.sh
$ ./cppall.sh p1437
$ clang++ p1437.cpp -std=c++03 -Wall
p1437.cpp:12:11: warning: variable 'b0p' is uninitialized when used within its own
initialization [-Wuninitialized]
int b0p = F(0p+0); // ill-formed; equivalent to “int b0p = b0p + 0;” in C++ 2014
~~~ ^~~~~~~
p1437.cpp:11:14: note: expanded from macro 'F'
#define F(a) b ## a
^~~~~~
<scratch space>:30:1: note: expanded from here
b0p
^~~
p1437.cpp:15:1: warning: 'auto' type specifier is a C++11 extension
[-Wc++11-extensions]
auto x1{1}; // was std::initializer_list<int>, now int
^
p1437.cpp:15:6: error: declaration of variable 'x1' with deduced type 'auto' requires
an initializer
auto x1{1}; // was std::initializer_list<int>, now int
^
p1437.cpp:15:8: error: expected ';' after top level declarator
auto x1{1}; // was std::initializer_list<int>, now int
^
;
p1437.cpp:18:11: error: expected function body after function declarator
void g1() noexcept;
^
p1437.cpp:37:10: error: using declaration cannot refer to a constructor
using A::A;
~~~^
p1437.cpp:45:47: warning: deleted function definitions are a C++11 extension
[-Wc++11-extensions]
template <typename T, T N> int foo(A2<N> *) = delete;
^
p1437.cpp:52:17: warning: deleted function definitions are a C++11 extension
[-Wc++11-extensions]
int f(char *) = delete;
^
In file included from p1437.cpp:57:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/set:389:
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/__tree:2424:26: error: no matching function
for call to object of type 'const std::__1::__tree<int, compare,
std::__1::allocator<int> >::value_compare' (aka 'const compare')
if (__p != end() && !value_comp()(__v, *__p))
^~~~~~~~~~~~
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/set:652:68: note: in instantiation of
function template specialization 'std::__1::__tree<int, compare,
std::__1::allocator<int> >::find<int>' requested here
const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
^
p1437.cpp:67:3: note: in instantiation of member function 'std::__1::set<int, compare,
std::__1::allocator<int> >::find' requested here
s.find(0);
^
p1437.cpp:60:6: note: candidate function not viable: 'this' argument has type 'const
std::__1::__tree<int, compare, std::__1::allocator<int> >::value_compare'
(aka 'const compare'), but method is not marked const
bool operator()(int a, int b)
^
In file included from p1437.cpp:57:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/set:389:
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/__tree:2503:14: error: no matching function
for call to object of type 'const std::__1::__tree<int, compare,
std::__1::allocator<int> >::value_compare' (aka 'const compare')
if (!value_comp()(__root->__value_, __v))
^~~~~~~~~~~~
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/__tree:2423:26: note: in instantiation of
function template specialization 'std::__1::__tree<int, compare,
std::__1::allocator<int> >::__lower_bound<int>' requested here
const_iterator __p = __lower_bound(__v, __root(), __end_node());
^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/set:652:68: note: in instantiation of
function template specialization 'std::__1::__tree<int, compare,
std::__1::allocator<int> >::find<int>' requested here
const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
^
p1437.cpp:67:3: note: in instantiation of member function 'std::__1::set<int, compare,
std::__1::allocator<int> >::find' requested here
s.find(0);
^
p1437.cpp:60:6: note: candidate function not viable: 'this' argument has type 'const
std::__1::__tree<int, compare, std::__1::allocator<int> >::value_compare'
(aka 'const compare'), but method is not marked const
bool operator()(int a, int b)
^
4 warnings and 6 errors generated.
$ clang++ p1437.cpp -std=c++11 -Wall
p1437.cpp:12:11: warning: variable 'b0p' is uninitialized when used within its own
initialization [-Wuninitialized]
int b0p = F(0p+0); // ill-formed; equivalent to “int b0p = b0p + 0;” in C++ 2014
~~~ ^~~~~~~
p1437.cpp:11:14: note: expanded from macro 'F'
#define F(a) b ## a
^~~~~~
<scratch space>:149:1: note: expanded from here
b0p
^~~
In file included from p1437.cpp:57:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/set:389:
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/__tree:1819:22: warning: the specified
comparator type does not provide a const call operator [-Wuser-defined-warnings]
__trigger_diagnostics()), "");
^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/set:400:28: note: in instantiation of
member function 'std::__1::__tree<int, compare, std::__1::allocator<int>
>::~__tree' requested here
class _LIBCPP_TEMPLATE_VIS set
^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/__tree:970:7: note: from 'diagnose_if'
attribute on '__trigger_diagnostics':
..._LIBCPP_DIAGNOSE_WARNING(!__invokable<_Compare const&, _Tp const&, _Tp const&>::value,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/__config:1130:20: note: expanded from macro
'_LIBCPP_DIAGNOSE_WARNING'
__attribute__((diagnose_if(__VA_ARGS__, "warning")))
^ ~~~~~~~~~~~
In file included from p1437.cpp:57:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/set:389:
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/__tree:2424:26: error: no matching function
for call to object of type 'const std::__1::__tree<int, compare,
std::__1::allocator<int> >::value_compare' (aka 'const compare')
if (__p != end() && !value_comp()(__v, *__p))
^~~~~~~~~~~~
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/set:652:68: note: in instantiation of
function template specialization 'std::__1::__tree<int, compare,
std::__1::allocator<int> >::find<int>' requested here
const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
^
p1437.cpp:67:3: note: in instantiation of member function 'std::__1::set<int, compare,
std::__1::allocator<int> >::find' requested here
s.find(0);
^
p1437.cpp:60:6: note: candidate function not viable: 'this' argument has type 'const
std::__1::__tree<int, compare, std::__1::allocator<int> >::value_compare'
(aka 'const compare'), but method is not marked const
bool operator()(int a, int b)
^
In file included from p1437.cpp:57:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/set:389:
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/__tree:2503:14: error: no matching function
for call to object of type 'const std::__1::__tree<int, compare,
std::__1::allocator<int> >::value_compare' (aka 'const compare')
if (!value_comp()(__root->__value_, __v))
^~~~~~~~~~~~
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/__tree:2423:26: note: in instantiation of
function template specialization 'std::__1::__tree<int, compare,
std::__1::allocator<int> >::__lower_bound<int>' requested here
const_iterator __p = __lower_bound(__v, __root(), __end_node());
^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/set:652:68: note: in instantiation of
function template specialization 'std::__1::__tree<int, compare,
std::__1::allocator<int> >::find<int>' requested here
const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
^
p1437.cpp:67:3: note: in instantiation of member function 'std::__1::set<int, compare,
std::__1::allocator<int> >::find' requested here
s.find(0);
^
p1437.cpp:60:6: note: candidate function not viable: 'this' argument has type 'const
std::__1::__tree<int, compare, std::__1::allocator<int> >::value_compare'
(aka 'const compare'), but method is not marked const
bool operator()(int a, int b)
^
2 warnings and 2 errors generated.
$ clang++ p1437.cpp -std=c++14 -Wall
p1437.cpp:12:11: warning: variable 'b0p' is uninitialized when used within its own
initialization [-Wuninitialized]
int b0p = F(0p+0); // ill-formed; equivalent to “int b0p = b0p + 0;” in C++ 2014
~~~ ^~~~~~~
p1437.cpp:11:14: note: expanded from macro 'F'
#define F(a) b ## a
^~~~~~
<scratch space>:237:1: note: expanded from here
b0p
^~~
In file included from p1437.cpp:57:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/set:389:
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/__tree:1819:22: warning: the specified
comparator type does not provide a const call operator [-Wuser-defined-warnings]
__trigger_diagnostics()), "");
^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/set:400:28: note: in instantiation of
member function 'std::__1::__tree<int, compare, std::__1::allocator<int>
>::~__tree' requested here
class _LIBCPP_TEMPLATE_VIS set
^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/__tree:970:7: note: from 'diagnose_if'
attribute on '__trigger_diagnostics':
..._LIBCPP_DIAGNOSE_WARNING(!__invokable<_Compare const&, _Tp const&, _Tp const&>::value,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/__config:1130:20: note: expanded from macro
'_LIBCPP_DIAGNOSE_WARNING'
__attribute__((diagnose_if(__VA_ARGS__, "warning")))
^ ~~~~~~~~~~~
In file included from p1437.cpp:57:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/set:389:
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/__tree:2424:26: error: no matching function
for call to object of type 'const std::__1::__tree<int, compare,
std::__1::allocator<int> >::value_compare' (aka 'const compare')
if (__p != end() && !value_comp()(__v, *__p))
^~~~~~~~~~~~
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/set:652:68: note: in instantiation of
function template specialization 'std::__1::__tree<int, compare,
std::__1::allocator<int> >::find<int>' requested here
const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
^
p1437.cpp:67:3: note: in instantiation of member function 'std::__1::set<int, compare,
std::__1::allocator<int> >::find' requested here
s.find(0);
^
p1437.cpp:60:6: note: candidate function not viable: 'this' argument has type 'const
std::__1::__tree<int, compare, std::__1::allocator<int> >::value_compare'
(aka 'const compare'), but method is not marked const
bool operator()(int a, int b)
^
In file included from p1437.cpp:57:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/set:389:
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/__tree:2503:14: error: no matching function
for call to object of type 'const std::__1::__tree<int, compare,
std::__1::allocator<int> >::value_compare' (aka 'const compare')
if (!value_comp()(__root->__value_, __v))
^~~~~~~~~~~~
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/__tree:2423:26: note: in instantiation of
function template specialization 'std::__1::__tree<int, compare,
std::__1::allocator<int> >::__lower_bound<int>' requested here
const_iterator __p = __lower_bound(__v, __root(), __end_node());
^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/set:652:68: note: in instantiation of
function template specialization 'std::__1::__tree<int, compare,
std::__1::allocator<int> >::find<int>' requested here
const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
^
p1437.cpp:67:3: note: in instantiation of member function 'std::__1::set<int, compare,
std::__1::allocator<int> >::find' requested here
s.find(0);
^
p1437.cpp:60:6: note: candidate function not viable: 'this' argument has type 'const
std::__1::__tree<int, compare, std::__1::allocator<int> >::value_compare'
(aka 'const compare'), but method is not marked const
bool operator()(int a, int b)
^
2 warnings and 2 errors generated.
$ clang++ p1437.cpp -std=c++17 -Wall
p1437.cpp:12:11: warning: variable 'b0p' is uninitialized when used within its own
initialization [-Wuninitialized]
int b0p = F(0p+0); // ill-formed; equivalent to “int b0p = b0p + 0;” in C++ 2014
~~~ ^~~~~~~
p1437.cpp:11:14: note: expanded from macro 'F'
#define F(a) b ## a
^~~~~~
<scratch space>:303:1: note: expanded from here
b0p
^~~
p1437.cpp:48:1: error: call to deleted function 'foo'
foo(p); // ill-formed; previously well-formed
^~~
p1437.cpp:45:32: note: candidate function [with T = int, N = 0] has been explicitly
deleted
template <typename T, T N> int foo(A2<N> *) = delete;
^
p1437.cpp:46:6: note: candidate function
void foo(void *);
^
p1437.cpp:55:9: error: call to deleted function 'f'
int x = f(s.data()); // ill-formed; previously well-formed
^
p1437.cpp:52:5: note: candidate function has been explicitly deleted
int f(char *) = delete;
^
p1437.cpp:53:5: note: candidate function
int f(const char *);
^
p1437.cpp:20:23: note: candidate function template not viable: requires 2 arguments,
but 1 was provided
template<class T> int f(T *, T *);
^
In file included from p1437.cpp:57:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/set:389:
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/__tree:1819:22: warning: the specified
comparator type does not provide a const call operator [-Wuser-defined-warnings]
__trigger_diagnostics()), "");
^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/set:400:28: note: in instantiation of
member function 'std::__1::__tree<int, compare, std::__1::allocator<int>
>::~__tree' requested here
class _LIBCPP_TEMPLATE_VIS set
^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/__tree:970:7: note: from 'diagnose_if'
attribute on '__trigger_diagnostics':
..._LIBCPP_DIAGNOSE_WARNING(!__invokable<_Compare const&, _Tp const&, _Tp const&>::value,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/__config:1130:20: note: expanded from macro
'_LIBCPP_DIAGNOSE_WARNING'
__attribute__((diagnose_if(__VA_ARGS__, "warning")))
^ ~~~~~~~~~~~
In file included from p1437.cpp:57:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/set:389:
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/__tree:2424:26: error: no matching function
for call to object of type 'const std::__1::__tree<int, compare,
std::__1::allocator<int> >::value_compare' (aka 'const compare')
if (__p != end() && !value_comp()(__v, *__p))
^~~~~~~~~~~~
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/set:652:68: note: in instantiation of
function template specialization 'std::__1::__tree<int, compare,
std::__1::allocator<int> >::find<int>' requested here
const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
^
p1437.cpp:67:3: note: in instantiation of member function 'std::__1::set<int, compare,
std::__1::allocator<int> >::find' requested here
s.find(0);
^
p1437.cpp:60:6: note: candidate function not viable: 'this' argument has type 'const
std::__1::__tree<int, compare, std::__1::allocator<int> >::value_compare'
(aka 'const compare'), but method is not marked const
bool operator()(int a, int b)
^
In file included from p1437.cpp:57:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/set:389:
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/__tree:2503:14: error: no matching function
for call to object of type 'const std::__1::__tree<int, compare,
std::__1::allocator<int> >::value_compare' (aka 'const compare')
if (!value_comp()(__root->__value_, __v))
^~~~~~~~~~~~
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/__tree:2423:26: note: in instantiation of
function template specialization 'std::__1::__tree<int, compare,
std::__1::allocator<int> >::__lower_bound<int>' requested here
const_iterator __p = __lower_bound(__v, __root(), __end_node());
^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/set:652:68: note: in instantiation of
function template specialization 'std::__1::__tree<int, compare,
std::__1::allocator<int> >::find<int>' requested here
const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
^
p1437.cpp:67:3: note: in instantiation of member function 'std::__1::set<int, compare,
std::__1::allocator<int> >::find' requested here
s.find(0);
^
p1437.cpp:60:6: note: candidate function not viable: 'this' argument has type 'const
std::__1::__tree<int, compare, std::__1::allocator<int> >::value_compare'
(aka 'const compare'), but method is not marked const
bool operator()(int a, int b)
^
2 warnings and 4 errors generated.
$ g++-7 p1437.cpp -std=c++03 -Wall
p1437.cpp:18:1: warning: identifier 'noexcept' is a keyword in C++11 [-Wc++11-compat]
void g1() noexcept;
^~~~
p1437.cpp:15:1: warning: 'auto' changes meaning in C++11; please remove it [-Wc++11-compat]
auto x1{1}; // was std::initializer_list<int>, now int
^~~~
p1437.cpp:15:6: error: 'x1' does not name a type
auto x1{1}; // was std::initializer_list<int>, now int
^~
p1437.cpp:18:11: error: expected initializer before 'noexcept'
void g1() noexcept;
^~~~~~~~
p1437.cpp:37:10: warning: inheriting constructors only available with -std=c++11 or -std=gnu++11
using A::A;
^
p1437.cpp:45:47: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11
template <typename T, T N> int foo(A2<N> *) = delete;
^~~~~~
p1437.cpp:52:17: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11
int f(char *) = delete;
^~~~~~
In file included from /usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/set:60:0,
from p1437.cpp:57:
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_tree.h: In instantiation of 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::find(const _Key&) const [with _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = compare; _Alloc = std::allocator<int>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<int>]':
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_set.h:770:29: required from 'std::set<_Key, _Compare, _Alloc>::const_iterator std::set<_Key, _Compare, _Alloc>::find(const key_type&) const [with _Key = int; _Compare = compare; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<int>; std::set<_Key, _Compare, _Alloc>::key_type = int]'
p1437.cpp:67:9: required from here
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_tree.h:2538:8: error: no match for call to '(const compare) (const int&, const int&)'
return (__j == end()
~~~~~~~~~~~~~
|| _M_impl._M_key_compare(__k,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_S_key(__j._M_node))) ? end() : __j;
~~~~~~~~~~~~~~~~~~~~~
p1437.cpp:60:6: note: candidate: bool compare::operator()(int, int) <near match>
bool operator()(int a, int b)
^~~~~~~~
p1437.cpp:60:6: note: passing 'const compare*' as 'this' argument discards qualifiers
In file included from /usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/set:60:0,
from p1437.cpp:57:
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_tree.h: In instantiation of 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_lower_bound(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type, std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Base_ptr, const _Key&) const [with _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = compare; _Alloc = std::allocator<int>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<int>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type = const std::_Rb_tree_node<int>*; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Base_ptr = const std::_Rb_tree_node_base*]':
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_tree.h:2536:42: required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::find(const _Key&) const [with _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = compare; _Alloc = std::allocator<int>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<int>]'
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_set.h:770:29: required from 'std::set<_Key, _Compare, _Alloc>::const_iterator std::set<_Key, _Compare, _Alloc>::find(const key_type&) const [with _Key = int; _Compare = compare; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<int>; std::set<_Key, _Compare, _Alloc>::key_type = int]'
p1437.cpp:67:9: required from here
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_tree.h:1888:6: error: no match for call to '(const compare) (const int&, const int&)'
if (!_M_impl._M_key_compare(_S_key(__x), __k))
p1437.cpp:60:6: note: candidate: bool compare::operator()(int, int) <near match>
bool operator()(int a, int b)
^~~~~~~~
p1437.cpp:60:6: note: passing 'const compare*' as 'this' argument discards qualifiers
$ g++-7 p1437.cpp -std=c++11 -Wall
In file included from /usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/set:60:0,
from p1437.cpp:57:
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_tree.h: In instantiation of 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::find(const _Key&) const [with _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = compare; _Alloc = std::allocator<int>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<int>]':
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_set.h:770:29: required from 'std::set<_Key, _Compare, _Alloc>::const_iterator std::set<_Key, _Compare, _Alloc>::find(const key_type&) const [with _Key = int; _Compare = compare; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<int>; std::set<_Key, _Compare, _Alloc>::key_type = int]'
p1437.cpp:67:9: required from here
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_tree.h:2538:8: error: no match for call to '(const compare) (const int&, const int&)'
return (__j == end()
~~~~~~~~~~~~~
|| _M_impl._M_key_compare(__k,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_S_key(__j._M_node))) ? end() : __j;
~~~~~~~~~~~~~~~~~~~~~
p1437.cpp:60:6: note: candidate: bool compare::operator()(int, int) <near match>
bool operator()(int a, int b)
^~~~~~~~
p1437.cpp:60:6: note: passing 'const compare*' as 'this' argument discards qualifiers
In file included from /usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/set:60:0,
from p1437.cpp:57:
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_tree.h: In instantiation of 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_lower_bound(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type, std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Base_ptr, const _Key&) const [with _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = compare; _Alloc = std::allocator<int>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<int>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type = const std::_Rb_tree_node<int>*; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Base_ptr = const std::_Rb_tree_node_base*]':
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_tree.h:2536:42: required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::find(const _Key&) const [with _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = compare; _Alloc = std::allocator<int>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<int>]'
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_set.h:770:29: required from 'std::set<_Key, _Compare, _Alloc>::const_iterator std::set<_Key, _Compare, _Alloc>::find(const key_type&) const [with _Key = int; _Compare = compare; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<int>; std::set<_Key, _Compare, _Alloc>::key_type = int]'
p1437.cpp:67:9: required from here
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_tree.h:1888:6: error: no match for call to '(const compare) (const int&, const int&)'
if (!_M_impl._M_key_compare(_S_key(__x), __k))
p1437.cpp:60:6: note: candidate: bool compare::operator()(int, int) <near match>
bool operator()(int a, int b)
^~~~~~~~
p1437.cpp:60:6: note: passing 'const compare*' as 'this' argument discards qualifiers
$ g++-7 p1437.cpp -std=c++14 -Wall
In file included from /usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/set:60:0,
from p1437.cpp:57:
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_tree.h: In instantiation of 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::find(const _Key&) const [with _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = compare; _Alloc = std::allocator<int>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<int>]':
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_set.h:770:29: required from 'std::set<_Key, _Compare, _Alloc>::const_iterator std::set<_Key, _Compare, _Alloc>::find(const key_type&) const [with _Key = int; _Compare = compare; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<int>; std::set<_Key, _Compare, _Alloc>::key_type = int]'
p1437.cpp:67:9: required from here
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_tree.h:2538:8: error: no match for call to '(const compare) (const int&, const int&)'
return (__j == end()
~~~~~~~~~~~~~
|| _M_impl._M_key_compare(__k,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_S_key(__j._M_node))) ? end() : __j;
~~~~~~~~~~~~~~~~~~~~~
p1437.cpp:60:6: note: candidate: bool compare::operator()(int, int) <near match>
bool operator()(int a, int b)
^~~~~~~~
p1437.cpp:60:6: note: passing 'const compare*' as 'this' argument discards qualifiers
In file included from /usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/set:60:0,
from p1437.cpp:57:
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_tree.h: In instantiation of 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_lower_bound(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type, std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Base_ptr, const _Key&) const [with _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = compare; _Alloc = std::allocator<int>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<int>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type = const std::_Rb_tree_node<int>*; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Base_ptr = const std::_Rb_tree_node_base*]':
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_tree.h:2536:42: required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::find(const _Key&) const [with _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = compare; _Alloc = std::allocator<int>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<int>]'
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_set.h:770:29: required from 'std::set<_Key, _Compare, _Alloc>::const_iterator std::set<_Key, _Compare, _Alloc>::find(const key_type&) const [with _Key = int; _Compare = compare; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<int>; std::set<_Key, _Compare, _Alloc>::key_type = int]'
p1437.cpp:67:9: required from here
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_tree.h:1888:6: error: no match for call to '(const compare) (const int&, const int&)'
if (!_M_impl._M_key_compare(_S_key(__x), __k))
p1437.cpp:60:6: note: candidate: bool compare::operator()(int, int) <near match>
bool operator()(int a, int b)
^~~~~~~~
p1437.cpp:60:6: note: passing 'const compare*' as 'this' argument discards qualifiers
$ g++-7 p1437.cpp -std=c++17 -Wall
p1437.cpp:11:14: error: pasting "b" and "0p+0" does not give a valid preprocessing token
#define F(a) b ## a
^
p1437.cpp:12:11: note: in expansion of macro 'F'
int b0p = F(0p+0); // ill-formed; equivalent to “int b0p = b0p + 0;” in C++ 2014
^
p1437.cpp:11:14: error: 'b' was not declared in this scope
#define F(a) b ## a
^
p1437.cpp:12:11: note: in expansion of macro 'F'
int b0p = F(0p+0); // ill-formed; equivalent to “int b0p = b0p + 0;” in C++ 2014
^
p1437.cpp: In function 'void bar(A2<0>*)':
p1437.cpp:48:6: error: use of deleted function 'int foo(A2<N>*) [with T = int; T N = 0'
foo(p); // ill-formed; previously well-formed
^
p1437.cpp:45:32: note: declared here
template <typename T, T N> int foo(A2<N> *) = delete;
^~~
p1437.cpp: At global scope:
p1437.cpp:55:19: error: use of deleted function 'int f(char*)'
int x = f(s.data()); // ill-formed; previously well-formed
^
p1437.cpp:52:5: note: declared here
int f(char *) = delete;
^
In file included from /usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/set:60:0,
from p1437.cpp:57:
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_tree.h: In instantiation of 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::find(const _Key&) const [with _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = compare; _Alloc = std::allocator<int>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<int>]':
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_set.h:770:29: required from 'std::set<_Key, _Compare, _Alloc>::const_iterator std::set<_Key, _Compare, _Alloc>::find(const key_type&) const [with _Key = int; _Compare = compare; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<int>; std::set<_Key, _Compare, _Alloc>::key_type = int]'
p1437.cpp:67:9: required from here
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_tree.h:2538:8: error: no match for call to '(const compare) (const int&, const int&)'
return (__j == end()
~~~~~~~~~~~~~
|| _M_impl._M_key_compare(__k,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_S_key(__j._M_node))) ? end() : __j;
~~~~~~~~~~~~~~~~~~~~~
p1437.cpp:60:6: note: candidate: bool compare::operator()(int, int) <near match>
bool operator()(int a, int b)
^~~~~~~~
p1437.cpp:60:6: note: passing 'const compare*' as 'this' argument discards qualifiers
In file included from /usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/set:60:0,
from p1437.cpp:57:
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_tree.h: In instantiation of 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_lower_bound(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type, std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Base_ptr, const _Key&) const [with _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = compare; _Alloc = std::allocator<int>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<int>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type = const std::_Rb_tree_node<int>*; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Base_ptr = const std::_Rb_tree_node_base*]':
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_tree.h:2536:42: required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::find(const _Key&) const [with _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = compare; _Alloc = std::allocator<int>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<int>]'
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_set.h:770:29: required from 'std::set<_Key, _Compare, _Alloc>::const_iterator std::set<_Key, _Compare, _Alloc>::find(const key_type&) const [with _Key = int; _Compare = compare; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<int>; std::set<_Key, _Compare, _Alloc>::key_type = int]'
p1437.cpp:67:9: required from here
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/stl_tree.h:1888:6: error: no match for call to '(const compare) (const int&, const int&)'
if (!_M_impl._M_key_compare(_S_key(__x), __k))
p1437.cpp:60:6: note: candidate: bool compare::operator()(int, int) <near match>
bool operator()(int a, int b)
^~~~~~~~
p1437.cpp:60:6: note: passing 'const compare*' as 'this' argument discards qualifiers
検討事項(agenda)
-std=c++11でコンパイルエラーにならず、他でコンパイルエラーになる背景の説明
役に立つまたは意味のある出力
参考資料(reference)
docker gnu(gcc/g++) and llvm(clang/clang++)
https://qiita.com/drafts/059874ea39c4de64c0f7
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 初稿 20180503