Top "Language-lawyer" questions

For questions about the intricacies of formal or authoritative specifications of programming languages and environments.

Is 'auto const' and 'const auto' the same?

Is there a semantic difference between auto const and const auto, or do they mean the same thing?

c++ c++11 language-lawyer constants auto
Is main a valid Java identifier?

One of my kids is taking Java in high school and had this on one of his tests: Which of …

java language-lawyer main identifier
The behaviour of floating point division by zero

Consider #include <iostream> int main() { double a = 1.0 / 0; double b = -1.0 / 0; double c = 0.0 / 0; std::cout << a <&…

c++ floating-point language-lawyer undefined-behavior divide-by-zero
When does invoking a member function on a null instance result in undefined behavior?

Consider the following code: #include <iostream> struct foo { // (a): void bar() { std::cout << "gman was here" &…

c++ undefined-behavior language-lawyer standards-compliance null-pointer
std::ignore with structured bindings?

Prelude: std::tuple<int, int, int> f(); std::tuple<int, int, float, int> g(); C++1z …

c++ language-lawyer c++17
What made i = i++ + 1; legal in C++17?

Before you start yelling undefined behaviour, this is explicitly listed in N4659 (C++17) i = i++ + 1; // the value of i is …

c++ language-lawyer c++17
Optimizing away a "while(1);" in C++0x

Updated, see below! I have heard and read that C++0x allows an compiler to print "Hello" for the following …

c++ loops c++11 language-lawyer undefined-behavior
What are the common undefined/unspecified behavior for C that you run into?

An example of unspecified behavior in the C language is the order of evaluation of arguments to a function. It …

c language-lawyer undefined-behavior unspecified-behavior
Valid, but worthless syntax in switch-case?

Through a little typo, I accidentally found this construct: int main(void) { char foo = 'c'; switch(foo) { printf("Cant Touch …

c switch-statement language-lawyer
trap representation

What is a "trap representation" in C (some examples might help)? Does this apply to C++? Given this code... float …

c++ c visual-studio-2010 gcc language-lawyer