Gang Of Coders
Home
About Us
Contact Us
All Language Lawyer Solutions on Gang of Coders
Total of 187 Language Lawyer Solutions
Why are arbitrary target expressions allowed in for-loops?
Python
For Loop
Language Lawyer
Does initialization entail lvalue-to-rvalue conversion? Is `int x = x;` UB?
C++
Initialization
Undefined Behavior
Language Lawyer
Using `throw;` on a modified exception
C++
Exception
Exception Handling
Language Lawyer
Throw
Does a[a[0]] = 1 produce undefined behavior?
C
Language Lawyer
C99
Undefined Behavior
Is std::is_unsigned<bool>::value well defined?
C++
Boolean
Language Lawyer
C++14
Unsigned
Are function return values automatic objects and thus guaranteed to be destructed?
C++
Exception Handling
Return
Return Value
Language Lawyer
Why is derived class move constructible when base class isn't?
C++
C++11
Language Lawyer
Move Semantics
Move Constructor
reinterpret_cast creating a trivially default-constructible object
C++
C++11
Language Lawyer
C++17
Why is the destructor called for an object that is not deleted?
C++
Language Lawyer
Do all pointers have the same size in C++?
C++
Pointers
Language Lawyer
Void Pointers
Strange "->* []" expression in C++ source code of cpp.react library
C++
C++11
Language Lawyer
Operator Arrow-Star
Do distinct functions have distinct addresses?
C++
Function Pointers
Language Lawyer
One Definition-Rule
Comdat Folding
Deleted default constructor. Objects can still be created... sometimes
C++
C++14
Language Lawyer
List Initialization
Aggregate Initialization
The behaviour of floating point division by zero
C++
Floating Point
Language Lawyer
Undefined Behavior
Divide by-Zero
Is ++*ptr++ undefined behaviour in c++?
C++
Language Lawyer
What does the standard say about how calling clear on a vector changes the capacity?
C++
Vector
Language Lawyer
Incomplete type in nested name specifier
C++
Language Lawyer
Accessing attributes on literals work on all types, but not `int`; why?
Python
Python 2.7
Python 3.x
Language Lawyer
Is sizeof(void()) a legal expression?
C++
Language Lawyer
Sizeof
Void
Constructor reference - no warning when generics array is created
Java
Generics
Java 8
Language Lawyer
Is stateful metaprogramming ill-formed (yet)?
C++
Language Lawyer
Metaprogramming
C++17
A positive lambda: '+[]{}' - What sorcery is this?
C++
C++11
Lambda
Operator Overloading
Language Lawyer
When is it valid to access a pointer to a "dead" object?
C
Pointers
Language Lawyer
Undefined Behavior
Why are are std::allocator's construct and destroy functions deprecated in c++17?
C++
Memory Management
Language Lawyer
Allocator
C++17
Can C++ code be valid in both C++03 and C++11 but do different things?
C++
C++11
Language Lawyer
C++03
Does the C standard permit assigning an arbitrary value to a pointer and incrementing it?
C
Pointers
Language Lawyer
Pointer Arithmetic
Why is unique_ptr not equality_comparable_with nullptr_t in C++20?
C++
Language Lawyer
C++20
C++ Concepts
Is it spread "syntax" or the spread "operator"?
Javascript
Ecmascript 6
Language Lawyer
Spread Syntax
Ternary operator implicit cast to base class
C++
Language Lawyer
C++17
Ternary Operator
Implicit Conversion
Access to protected member through member-pointer: is it a hack?
C++
Language Lawyer
Protected
Access Specifier
Member Pointers
Is std::memcpy between different trivially copyable types undefined behavior?
C++
Language Lawyer
C++17
Undefined Behavior
Strict Aliasing
Why can const char* const & = "hello" compile?
C++
Reference
Constants
Language Lawyer
Is it possible to get a pointer to one subobject via a pointer to a different, unreleated subobject?
C++
Pointers
Language Lawyer
C++17
Offsetof
Why must I provide 'operator ==' when 'operator <=>' is enough?
C++
Language Lawyer
C++20
Language Design
Spaceship Operator
Is `long` guaranteed to be at least 32 bits?
C++
Standards
Long Integer
Language Lawyer
Is &errno legal C?
C
Language Lawyer
Errno
Is a moved-from vector always empty?
C++
C++11
Vector
Language Lawyer
Move Semantics
Is C++ allowed to increase the derived class size if there're no new member variables compared to the base class?
C++
Inheritance
Sizeof
Language Lawyer
Why is S::x not odr-used?
C++
Language Lawyer
C++17
What's the meaning of "reserved for any use"?
C++
C
Language Lawyer
C Standard-Library
Difference between i++ and (i)++ in C
C
Language Lawyer
Increment
Evaluation
Do std::min(0.0, 1.0) and std::max(0.0, 1.0) yield undefined behavior?
C++
Floating Point
Language Lawyer
Undefined Behavior
C++ Standard-Library
Why is std::move not [[nodiscard]] in C++20?
C++
C++17
Language Lawyer
C++20
Nodiscard
Absolute value abs(x) using bitwise operators and Boolean logic
C++
C
Bit Manipulation
Language Lawyer
Absolute Value
Will std::string always be null-terminated in C++11?
C++
String
C++11
Language Lawyer
Null Terminated
Repeated typedefs - invalid in C but valid in C++?
C++
C
Typedef
Language Lawyer
Why is it not possible to overload class templates?
C++
Templates
Overloading
Template Specialization
Language Lawyer
Is main a valid Java identifier?
Java
Language Lawyer
Main
Identifier
Is the "lazy man's enable_if" legal C++?
C++
C++11
Visual C++
Language Lawyer
Sfinae
What is the name of this unusual C++ template feature used by Boost.Spirit?
C++
Templates
C++11
Language Lawyer
Boost Spirit
C++20 bit_cast vs reinterpret_cast
C++
Language Lawyer
Type Alias
C++20
Pointer arithmetics with two different buffers
C++
Pointers
Language Lawyer
Pointer Arithmetic
Why does left shift operation invoke Undefined Behaviour when the left side operand has negative value?
C++
C
Language Lawyer
Undefined Behavior
Bit Shift
Different Pointer Arithmetic Results when Taking Address of Array
C
Pointers
Language Lawyer
Why is f(i = -1, i = -1) undefined behavior?
C++
Language Lawyer
Undefined Behavior
What are Rust's exact auto-dereferencing rules?
Rust
Reference
Language Lawyer
In CSS Flexbox, why are there no "justify-items" and "justify-self" properties?
Css
Flexbox
Language Lawyer
W3c
Valid, but worthless syntax in switch-case?
C
Switch Statement
Language Lawyer
What made i = i++ + 1; legal in C++17?
C++
Language Lawyer
C++17
Does C++11, 14, 17 or 20 introduce a standard constant for pi?
C++
C++11
C++14
Language Lawyer
C++17
What happens if you static_cast invalid value to enum class?
C++
Language Lawyer
Optimizing away a "while(1);" in C++0x
C++
Loops
C++11
Language Lawyer
Undefined Behavior
Is the operation "false < true" well defined?
C++
Boolean
Language Lawyer
Comparison Operators
How do I make an infinite empty loop that won't be optimized away?
C
Clang
Language Lawyer
Compiler Optimization
Accessing inactive union member and undefined behavior?
C++
Undefined Behavior
Language Lawyer
Unions
C++ zero initialization - Why is `b` in this program uninitialized, but `a` is initialized?
C++
Initialization
Language Lawyer
Copy/move assignment in std::vector::erase() and std::deque::erase()
C++
Language Lawyer
C++14
How does this piece of code determine array size without using sizeof( )?
C
Arrays
Size
Language Lawyer
Pointer Arithmetic
Is null reference possible?
C++
Reference
Null
Language Lawyer
Is it safe to push_back an element from the same vector?
C++
Vector
Reference
Language Lawyer
Push Back
What is "callback hell" and how and why does RX solve it?
Javascript
Callback
Language Lawyer
Reactive Programming
Rxjs
Lambda returning itself: is this legal?
C++
Lambda
Language Lawyer
C++17
Auto
Definition of "==" operator for Double
C#
.Net
Language Lawyer
Is using if (0) to skip a case in a switch supposed to work?
C++
C
If Statement
Switch Statement
Language Lawyer
When does invoking a member function on a null instance result in undefined behavior?
C++
Undefined Behavior
Language Lawyer
Standards Compliance
Null Pointer
Lambda capture and parameter with same name - who shadows the other? (clang vs gcc)
C++
C++11
Lambda
Language Lawyer
Shadowing
Why does the delete[] syntax exist in C++?
C++
Memory Management
Syntax
Language Lawyer
Standards
Why does the ternary operator with commas evaluate only one expression in the true case?
C++
Language Lawyer
Operator Precedence
Conditional Operator
When using C headers in C++, should we use functions from std:: or the global namespace?
C++
Language Lawyer
Std
Program being compiled differently in 3 major C++ compilers. Which one is right?
C++
Language Lawyer
Is passing a C++ object into its own constructor legal?
C++
Class
Constructor
Language Lawyer
Undefined Behavior
Does C++20 mandate source code being stored in files?
C++
Language Lawyer
C++20
Std Source-Location
std::ignore with structured bindings?
C++
C++17
Language Lawyer
Structured Bindings
Std Tie
Confusion about array initialization in C
C
Arrays
Initialization
Language Lawyer
Efficient unsigned-to-signed cast avoiding implementation-defined behavior
C++
Casting
Integer
Language Lawyer
Integer Overflow
Does "Undefined Behavior" really permit *anything* to happen?
C++
C
Language Lawyer
Undefined Behavior
Have there ever been silent behavior changes in C++ with new standard versions?
C++
Language Lawyer
Standardization
Effectively final vs final - Different behavior
Java
Language Lawyer
Final
Jls
Effectively Final
C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?
C++
Multithreading
C++11
Language Lawyer
Memory Model
Why is "using namespace X;" not allowed at class/struct level?
C++
Namespaces
Using
Language Lawyer
C++ - Why static member function can't be created with 'const' qualifier
C++
Static
Language Lawyer
Const Method
Is "else if" a single keyword?
C++
Syntax
Language Lawyer
Is it still safe to delete nullptr in c++0x?
C++
Null
Language Lawyer
Delete Operator
How can a program with a global variable called main instead of a main function work?
C++
Main
Language Lawyer
When is a private constructor not a private constructor?
C++
C++11
Language Lawyer
Default Constructor
Aggregate Initialization
When do extra parentheses have an effect, other than on operator precedence?
C++
C++11
Language Lawyer
Parentheses
C++ Faq
Does this code from "The C++ Programming Language" 4th edition section 36.3.6 have well-defined behavior?
C++
C++11
Language Lawyer
Operator Precedence
Unspecified Behavior
Printing null pointers with %p is undefined behavior?
C
Language Lawyer
C99
Undefined Behavior
C11
How many levels of pointers can we have?
C++
C
Pointers
Language Lawyer
Limit
Why do (only) some compilers use the same address for identical string literals?
C++
Language Lawyer
String Literals
String Interning
Error when using in-class initialization of non-static data member and nested class constructor
C++
C++11
Language Lawyer
When does type information flow backwards in C++?
C++
Types
Language Lawyer
C++17
Type Deduction
Is 'auto const' and 'const auto' the same?
C++
C++11
Language Lawyer
Constants
Auto
Can branches with undefined behavior be assumed unreachable and optimized as dead code?
C++
Language Lawyer
Undefined Behavior
Dead Code
Unreachable Code
trap representation
C++
C
Visual Studio-2010
Gcc
Language Lawyer
Is this a known pitfall of C++11 for loops?
C++
For Loop
C++11
Language Lawyer
Foreach
Why are async state machines classes (and not structs) in Roslyn?
C#
.Net
Language Lawyer
Roslyn
Different behaviour of comma operator in C++ with return?
C++
Return
Language Lawyer
Operator Precedence
Comma Operator
Why are references not "const" in C++?
C++
Reference
Constants
Language Lawyer
Decltype
Why do C and C++ allow the expression (int) + 4*5?
C++
C
Casting
Language Lawyer
Is a pointer with the right address and type still always a valid pointer since C++17?
C++
Pointers
C++14
Language Lawyer
C++17
Pure Functions: Does "No Side Effects" Imply "Always Same Output, Given Same Input"?
Javascript
Functional Programming
Language Lawyer
Pure Function
Is it legal for source code containing undefined behavior to crash the compiler?
C++
Language Lawyer
Undefined Behavior
Is `new` in `new int;` considered an operator?
C++
Language Lawyer
Is it guaranteed to be safe to perform memcpy(0,0,0)?
C
Memcpy
Language Lawyer
Null Pointer
Can argc be zero on a POSIX system?
C
Posix
Language Lawyer
Main
Can code that will never be executed invoke undefined behavior?
C
Language Lawyer
Is it allowed for a compiler to optimize away a local volatile variable?
C++
Language Lawyer
C++17
Volatile
Will consteval functions allow template parameters dependent on function arguments?
C++
Language Lawyer
Constexpr
C++20
Class Template
What is the size of void?
C++
C
Language Lawyer
Sizeof
Capturing a reference by reference in a C++11 lambda
C++
C++11
Lambda
Language Lawyer
How can this structure have sizeof == 0?
C++
Language Lawyer
Sizeof
What is difference between const and non const key?
C++
Key
Language Lawyer
Key Value
Stdmap
Take the address of a one-past-the-end array element via subscript: legal by the C++ Standard or not?
C++
C
Standards
Language Lawyer
Different cast operator called by different compilers
C++
Language Lawyer
Can I use NULL as substitution for the value of 0?
C++
C
Pointers
Null
Language Lawyer
Why is 019 not a JavaScript syntax error? Or why is 019 > 020
Javascript
Grammar
Language Lawyer
Ecmascript 5
Javacc
Why is a const variable sometimes not required to be captured in a lambda?
C++
Lambda
Constants
Language Lawyer
Cv-qualifications of prvalues (revisited)
C++
Language Lawyer
C++17
Temporary Objects
Prvalue
What are the valid signatures for C's main() function?
C
Language Lawyer
Signature
Entry Point
Function Prototypes
Type of `this` in static member function?
C++
C++11
Language Lawyer
Is masking before unsigned left shift in C/C++ too paranoid?
C++
C
Language Lawyer
Undefined Behavior
Integer Arithmetic
Why would the behavior of std::memcpy be undefined for objects that are not TriviallyCopyable?
C++
C++11
Language Lawyer
Memcpy
Object Lifetime
Does C or C++ guarantee array < array + SIZE?
C++
C
Language Lawyer
Is the compiler allowed to optimize out heap memory allocations?
C++
Gcc
Optimization
Clang
Language Lawyer
What are the common undefined/unspecified behavior for C that you run into?
C
Language Lawyer
Undefined Behavior
Unspecified Behavior
std::tuple sizeof, is it a missed optimization?
C++
Tuples
Language Lawyer
Padding
Why don't I need to specify "typename" before a dependent type in C++20?
C++
Templates
Language Lawyer
C++20
Typename
Why was the space character not chosen for C++14 digit separators?
C++
Language Lawyer
C++14
Digit
Is it legal to compare dangling pointers?
C++
Pointers
Language Lawyer
Dangling Pointer
Why does the compiler match "char" to "int" but not "short"?
C++
Type Conversion
Overloading
Language Lawyer
Is copying 2D arrays with "memcpy" technically undefined behaviour?
C++
C
Multidimensional Array
Language Lawyer
Undefined Behavior
Is std::stoi actually safe to use?
C++
Standards
Language Lawyer
Can using a lambda in header files violate the ODR?
C++
C++11
Lambda
Language Lawyer
One Definition-Rule
Return void type in C and C++
C++
C
Gcc
Clang
Language Lawyer
Initializing an array of zeroes
C++
Arrays
Initialization
Language Lawyer
Exact moment of "return" in a C++-function
C++
Language Lawyer
C++17
Object Lifetime
Copy Elision
How do I specify an integer literal of type unsigned char in C++?
C++
Integer
Constants
Language Lawyer
What is the behavior of printing NULL with printf's %s specifier?
C
Linux
Language Lawyer
Compiler Bug
Could a C++ implementation, in theory, parallelise the evaluation of two function arguments?
C++
Language Lawyer
Why is a double semicolon a SyntaxError in Python?
Python
Syntax Error
Language Lawyer
De Morgan's Law optimization with overloaded operators
C++
Operator Overloading
Language Lawyer
Compiler Optimization
Could it be the case that sizeof(T*) != sizeof(const T*)?
C++
Language Lawyer
int a[] = {1,2,}; Why is a trailing comma in an initializer-list allowed?
C++
Syntax
Grammar
Language Lawyer
Why isn't `std::initializer_list` defined as a literal type?
C++
Language Lawyer
C++14
Initializer List
Constexpr
Pure virtual functions may not have an inline definition. Why?
C++
Pure Virtual
Language Lawyer
Using std::bind with member function, use object pointer or not for this argument?
C++
C++11
Language Lawyer
Can the compiler optimize from heap to stack allocation?
C++
Memory Management
Language Lawyer
Compiler Optimization
Is a C compiler allowed to coalesce sequential assignments to volatile variables?
C
Language Lawyer
Compiler Optimization
Volatile
In C++, does initializing a global variable with itself have undefined behaviour?
C++
Language Lawyer
Undefined Behavior
reinterpret_cast between char* and std::uint8_t* - safe?
C++
C++11
Language Lawyer
Strict Aliasing
Uint8t
Redefining lambdas not allowed in C++11, why?
C++
C++11
Lambda
Language Lawyer
Has C++ standard changed with respect to the use of indeterminate values and undefined behavior in C++14?
C++
C++11
Language Lawyer
Undefined Behavior
C++14
Do we really need "enum class" in C++11?
C++
Enums
C++11
Language Lawyer
Why does clang's stdbool.h contain #define false false
C++
Clang
Language Lawyer
If two objects are declared in a single line, in which order are they constructed?
C++
Language Lawyer
Declaration
Object Construction
Changed rules for protected constructors in C++17?
C++
Constructor
Language Lawyer
C++17
Protected
Fortran: integer*4 vs integer(4) vs integer(kind=4)
Fortran
Language Lawyer
Are int8_t and uint8_t intended to be char types?
C++
C++11
Iostream
Language Lawyer
Standard Library
Is 0 an octal or a decimal in C?
C
Language Lawyer
Literals
Octal
Is x = std::move(x) undefined?
C++
C++11
Language Lawyer
C++14
Is unevaluated division by 0 undefined behavior?
C++
C
Language Lawyer
Class static variable initialization order
C++
Scope
Language Lawyer
Why does C++11 contain an odd clause about comparing void pointers?
C++
C++11
Pointers
Language Lawyer
Comparison Operators
Why did the range based 'for' loop specification change in C++17?
C++
For Loop
Language Lawyer
C++17
Does new char actually guarantee aligned memory for a class type?
C++
C++11
Language Lawyer
Does `sizeof` *really* evaluate to a `std::size_t`? Can it?
C++
C++11
Std
Language Lawyer
Do C++ enums Start at 0?
C++
Enums
Language Lawyer
Enumeration
Ordinal
What is the type of null literal?
C#
.Net
Language Lawyer
Does &((struct name *)NULL -> b) cause undefined behaviour in C11?
C
Language Lawyer
C11
Offsetof
C++ switch statement expression evaluation guarantee
C++
Standards
Language Lawyer
Why does `int ;` compile fine in C, but not in C++?
C++
C
Gcc
Language Lawyer
Variable Declaration
Addition assignment += behavior in expression
Javascript
Java
Language Lawyer
Compound Assignment
Why does the order of template argument substitution matter?
C++
Templates
C++11
Language Lawyer
C++14
What changes introduced in C++14 can potentially break a program written in C++11?
C++
C++11
C++14
Language Lawyer
C++ Faq
Does a declaration using "auto" match an extern declaration that uses a concrete type specifier?
C++
Language Lawyer
Extern
Auto
Is ++x %= 10 well-defined in C++?
C++
Language Lawyer
Undefined Behavior
Evaluation