Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In the C language, using an initialized variable isn't an error but an Undefined Behavior.</p> <p>Undefined behavior exists because C is designed to be a very efficient low-level language. Using an initialized variable is undefined behavior because it allows the compiler to optimize the variable allocation, as no default value is required.</p> <p>But the compiler is licensed to do whatever he wants when an undefined behavior occurs. The C Standard FAQ says:</p> <blockquote> <p>Anything at all can happen; the Standard imposes no requirements. The program may fail to compile, or it may execute incorrectly (either crashing or silently generating incorrect results), or it may fortuitously do exactly what the programmer intended.</p> </blockquote> <p>So any implementation of an undefined behavior is valid (even if it produces code that formats your hard drive).</p> <p>Xcode uses different optizations for Debug and Release configurations. Debug configuration has no optimization (<code>-O0</code> flag) so the compiled executable must stays close to your code, allowing you to debug it more easily. On the other hand, Release configuration produces strongly optimized executables (<code>-Os</code> flag) because you want your application to run fast.</p> <p>Due to that difference, undefined behaviours may (or may not) produce different results in Release and Debug configurations.</p> <p>Though the LLVM compiler is quite verbose, it does not emit warnings by default for undefined behaviors. You may however run the static analyzer, which can detect that kind of issues.</p> <p>More information about undefined behaviors and how they are handled by compilers in <a href="http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html" rel="nofollow">What Every Programmer Should Know About Undefined Behavior</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload