Are pointers of different types layout-compatible?
I’m trying to determine if two structs are layout-compatible. In my case, it’s not clear to me if pointers of different types are considered compatible. In the following example, are structs t1
and t2
layout-compatible?
Explicit this member function use acceted by msvc but rejected by clang and gcc
I wrote the following program that compiles with msvc but rejected by clang and gcc. It uses explicit object member function. Demo.
Declaring class members using a constructor with constant parameters
Considering the code below, in the Bar
class, member
needs to be constructed with the constant 33
. The way to go is using an initializer list like in the #if 1
version.
Does s conversion specifier specify direction / order in which characters are written?
Does s
conversion specifier specify direction / order in which characters are written?
Is `&Arr[std::size(Arr)]` undefined behaviour?
Let’s say int Arr[2];
. Is &Arr[2]
undefined in C++? This is attempting to get the past-the-end pointer to the hypothetical 3rd element, (Arr + 2)
or std::end(Arr)
.
is this Undefined Behavior? (casting away const from a temporary binding to const reference)
is the following code undefined
is this Undefined Bahvoir? (casting away const from a temporary binding to const reference)
is the following code undefined
Why are pointers to data members callable in C++?
Under the “Callable” page at cppreference it states:
Why are pointers to members callable in C++?
Under the “Callable” page at cppreference it states:
Should std::variant be nothrow destructible when its alternative has potentially throwing destructor?
TL;DR: see compilers disagree on code by Godbolt link: https://godbolt.org/z/f7G6PTEsh