Is the operation “false < true" well defined?

TL;DR: The operations are well defined according to the draft C++ standard. Details We can see that by going to the draft C++ standard section 5.9 Relational operators which says (emphasis mine going forward): The operands shall have arithmetic, enumeration, or pointer type, or type std::nullptr_t. The operators < (less than), > (greater than), <= … Read more

Optimizing away a “while(1);” in C++0x

To me, the relevant justification is: This is intended to allow compiler transfor- mations, such as removal of empty loops, even when termination cannot be proven. Presumably, this is because proving termination mechanically is difficult, and the inability to prove termination hampers compilers which could otherwise make useful transformations, such as moving nondependent operations from … Read more

What made i = i++ + 1; legal in C++17?

In C++11 the act of “assignment”, i.e. the side-effect of modifying the LHS, is sequenced after the value computation of the right operand. Note that this is a relatively “weak” guarantee: it produces sequencing only with relation to value computation of the RHS. It says nothing about the side-effects that might be present in the … Read more

Is main a valid Java identifier?

public class J { public static void main(String[] args) { String main = “The character sequence \”main\” is an identifier, not a keyword or reserved word.”; System.out.println(main); } } This compiles, and when executed, emits this output: The character sequence “main” is an identifier, not a keyword or reserved word. The character sequence main is … Read more

A positive lambda: ‘+[]{}’ – What sorcery is this? [duplicate]

Yes, the code is standard conforming. The + triggers a conversion to a plain old function pointer for the lambda. What happens is this: The compiler sees the first lambda ([]{}) and generates a closure object according to §5.1.2. As the lambda is a non-capturing lambda, the following applies: 5.1.2 Lambda expressions [expr.prim.lambda] 6 The … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)