I was using the std::tuple class and found something I would say is rather unexpected behavior.Consider the code:
If the exception is thrown by the C++ code but is not caught, it causes SIGABRT. Some systems just print "Abort", some other systems also print the contents of e.what().
I have structure like below.and union like below.and I type pun as below.pointer->res.a is fine but the behaviour of pointer->res.b is undefined.
I have this simple code:This produces an error in bla():My Question is: WHY?Note: used g++ 5.4 and 7.3.
In the following code (tested locally and on Wandbox):MSVC 15.8.5 fails to compile with:(all referring to the line containing constexpr)
Given this example:The errors are as described in the comments. gcc 8.2.1 and clang 7.0.1 were used and disagree about what is happening in this example. Could someone clarify this?
Lets look at the following code:[expr.reinterpret.cast]/11:A glvalue expression of type T1 can be cast to the type “reference to T2” if an expression of type “pointer to T1” can be explicitly converted to the type “pointer to T2” using a reinterpret_cast. The result refers to the same object as the...
I'm having trouble understanding the difference between unspecified and undefined behavior. I think trying to understand some examples would be useful. For instance, x = x++. The problem with this assignment is that:
I noticed just now that the following code can be compiled with clang/gcc/clang++/g++, using c99, c11, c++11 standards.
Let me give a concrete example to make it more clear what I exactly mean.I have two drafts of C++ standard: N4296 that is quite old now and more recent revision N4750. There are some subsections that I am interested in, e.g. [unord.hash]. Version N4296 requires from std::hash to provide...