C++ N4606(126)11 Member access control [class.access]p269
https://qiita.com/kaizen_nagoya/items/1ead00dff84aca76123f
で、間違えて1行、プログラム以外を紛れ込ませたら、
clang++
g++
でエラーの出方が極端に違った。記録。
<この項は書きかけです。順次追記します。>
// N4606 Committee Draft, Standard for Programming Language C++
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/n4606.pdf
#define msg "p269.cpp(126)11 Member access control [class.access]"
#include <iostream>
union are public by default. [ Example:
class X {
int a; // X::a is private by default
};
struct S {
int a; // S::a is public by default
};
class A {
class B { };
public:
typedef B BB;
};
void f() {
A::BB x; // OK, typedef name A::BB is public
A::B y; // access error, A::B is private
}
class A {
typedef int I; // private member
I f();
friend I g(I);
static I x;
template<int> struct Q;
template<int> friend struct R;
protected:
struct B { };
};
A::I A::f() { return 0; }
A::I g(A::I p = A::x);
A::I g(A::I p) { return 0; }
A::I A::x = 0;
template<A::I> struct A::Q { };
template<A::I> struct R { };
struct D: A::B, A { };
class B { };
template <class T> class C {
protected:
typedef T TT;
};
template <class U, class V = typename U::TT>
class D : public U { };
D <C<B> >* d; // access error, C::TT is protected
int main(){
std::cout<< msg << std::endl;
return EXIT_SUCCESS;
}
$ ./cppgl17.sh p269
$ clang++ p269.cpp
p269.cpp:7:11: error: expected unqualified-id
union are public by default. [ Example:
^
1 error generated.
$ g++-7 p269.cpp
p269.cpp:7:11: error: expected unqualified-id before 'public'
union are public by default. [ Example:
^~~~~~
p269.cpp: In function 'void f()':
p269.cpp:22:4: error: 'class A::B' is private within this context
A::B y; // access error, A::B is private
^
p269.cpp:16:7: note: declared private here
class B { };
^
p269.cpp: At global scope:
p269.cpp:25:7: error: redefinition of 'class A'
class A {
^
p269.cpp:15:7: note: previous definition of 'class A'
class A {
^
p269.cpp:35:4: error: 'I' in 'class A' does not name a type
A::I A::f() { return 0; }
^
p269.cpp:36:4: error: 'I' in 'class A' does not name a type
A::I g(A::I p = A::x);
^
p269.cpp:37:4: error: 'I' in 'class A' does not name a type
A::I g(A::I p) { return 0; }
^
p269.cpp:38:4: error: 'I' in 'class A' does not name a type
A::I A::x = 0;
^
p269.cpp:39:10: error: 'A::I' has not been declared
template<A::I> struct A::Q { };
^
p269.cpp:39:28: error: qualified name does not name a class before '{' token
template<A::I> struct A::Q { };
^
p269.cpp:40:10: error: 'A::I' has not been declared
template<A::I> struct R { };
^
p269.cpp:41:14: error: 'class A::B' is private within this context
struct D: A::B, A { };
^
p269.cpp:16:7: note: declared private here
class B { };
^
p269.cpp:50:7: error: 'D' is not a template
class D : public U { };
^
p269.cpp:41:8: note: previous declaration here
struct D: A::B, A { };
^
p269.cpp:51:1: error: 'D' is not a template
D <C<B> >* d; // access error, C::TT is protected
^
わかったこと
clang++致命的なエラーがある場合はそれ以降をコンパイルしない。
clang++はエラー20を超えたらそれ以上はコンパイルしない。
Reference
Error一覧 error(0)
https://qiita.com/kaizen_nagoya/items/48b6cbc8d68eae2c42b8
C++ Support(0)
https://qiita.com/kaizen_nagoya/items/8720d26f762369a80514
Coding Rules(0) C Secure , MISRA and so on
https://qiita.com/kaizen_nagoya/items/400725644a8a0e90fbb0
Ethernet 記事一覧 Ethernet(0)
https://qiita.com/kaizen_nagoya/items/88d35e99f74aefc98794
Wireshark 一覧 wireshark(0)、Ethernet(48)
https://qiita.com/kaizen_nagoya/items/fbed841f61875c4731d0
線網(Wi-Fi)空中線(antenna)(0) 記事一覧(118/300目標)
https://qiita.com/kaizen_nagoya/items/5e5464ac2b24bd4cd001
OSEK OS設計の基礎 OSEK(100)
https://qiita.com/kaizen_nagoya/items/7528a22a14242d2d58a3
Error一覧(C/C++, python, bash...) Error(0)
https://qiita.com/kaizen_nagoya/items/48b6cbc8d68eae2c42b8
なぜdockerで機械学習するか 書籍・ソース一覧作成中 (目標100)
https://qiita.com/kaizen_nagoya/items/ddd12477544bf5ba85e2
言語処理100本ノックをdockerで。python覚えるのに最適。:10+12
https://qiita.com/kaizen_nagoya/items/7e7eb7c543e0c18438c4
プログラムちょい替え(0)一覧:4件
https://qiita.com/kaizen_nagoya/items/296d87ef4bfd516bc394
TOPPERSまとめ #名古屋のIoTは名古屋のOSで
https://qiita.com/kaizen_nagoya/items/9026c049cb0309b9d451
docker(0) 資料集
https://qiita.com/kaizen_nagoya/items/45699eefd62677f69c1d
Qiita-dockerお宝鑑定団
https://qiita.com/kaizen_nagoya/items/509e125263559b5aed5b
The C++ Standard Library: clang++とg++でコンパイルしてみた(まとめ):14件
https://qiita.com/kaizen_nagoya/items/9bdfaa392443d13e5759
C++17 - The Complete Guide clang++とg++でコンパイルしてみた(まとめ):4件
https://qiita.com/kaizen_nagoya/items/c000f307e642990781e1
C++N3242, 2011, ISO/IEC 14882, C++ standard(1) Example code compile list
https://qiita.com/kaizen_nagoya/items/685b5c1a2c17c1bf1318
C++N4606 Working Draft 2016, ISO/IEC 14882, C++ standard(1) Example code compile list
https://qiita.com/kaizen_nagoya/items/df5d62c35bd6ed1c3d43/
C++N4741, 2018 Standard Working Draft on ISO/IEC 14882 sample code compile list
https://qiita.com/kaizen_nagoya/items/3294c014044550896010
C++N4910:2022 Standard Working Draft on ISO/IEC 14882(0) sample code compile list
https://qiita.com/kaizen_nagoya/items/fc957ddddd402004bb91
Autosar Guidelines C++14 example code compile list(1-169)
https://qiita.com/kaizen_nagoya/items/8ccbf6675c3494d57a76
プログラマによる、プログラマのための、統計と確率のプログラミングとその後 統計と確率一覧(0)
https://qiita.com/kaizen_nagoya/items/6e9897eb641268766909
一覧の一覧( The directory of directories of mine.) Qiita(100)
https://qiita.com/kaizen_nagoya/items/7eb0e006543886138f39
<この記事は個人の過去の経験に基づく個人の感想です。現在所属する組織、業務とは関係がありません。>
This article is an individual impression based on the individual's experience. It has nothing to do with the organization or business to which I currently belong.
文書履歴
ver 0.10 初稿 20180419
ver 0.11 初めの説明追記 20180420
ver. 0.12 ありがとう追記 20230312
最後までおよみいただきありがとうございました。
いいね 💚、フォローをお願いします。
Thank you very much for reading to the last sentence.
Please press the like icon 💚 and follow me for your happy life.