Most efficient standard-compliant way of reinterpreting int as float

Afaik, there are only two approaches that are compliant with strict aliasing rules: memcpy() and cast to char* with copying. All others read a float from memory that belongs to an uint32_t, and the compiler is allowed to perform the read before the write to that memory location. It might even optimize away the write … Read more

Valid characters for URI schemes?

According to RFC 2396, Appendix A: scheme = alpha *( alpha | digit | “+” | “-” | “.” ) Meaning: The scheme should start with a letter (upper or lower case), and can contains letters (still upper and lower case), number, “+”, “-” and “.”. Note: in the case of paparazzi:http:[//<host>[:[<port>][<transport>]]/ the scheme is … Read more

When does invoking a member function through a null pointer result in undefined behavior?

Both (a) and (b) result in undefined behavior. It’s always undefined behavior to call a member function through a null pointer. If the function is static, it’s technically undefined as well, but there’s some dispute. The first thing to understand is why it’s undefined behavior to dereference a null pointer. In C++03, there’s actually a … Read more

Is it valid to have an HTML form inside another HTML form? [duplicate]

A. It is not valid HTML nor XHTML In the official W3C XHTML specification, Section B. “Element Prohibitions”, states that: “form must not contain other form elements.” http://www.w3.org/TR/xhtml1/#prohibitions As for the older HTML 3.2 spec, the section on the FORMS element states that: “Every form must be enclosed within a FORM element. There can be … Read more

Why class { int i; }; is not fully standard-conformant?

Clause 9 of the standard allows class {public: int i;} (note the lack of a final semicolon) because this decl-specifier-seq for an unnamed class might be used in some other construct such as a typedef or a variable declaration. The problem with class {public: int i;}; (note that the final semicolon is now present) is … Read more

How universally is C99 supported?

If you want to write portable C code, then I’d suggest you to write in C89 (old ANSI C standard). This standard is supported by most compilers. The Intel C Compiler has very good C99 support and it produces fast binaries. (Thanks 0x69!) MSVC supports some new features and Microsoft plan to broaden support in … Read more

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