... | ... | @@ -38,12 +38,16 @@ If even a non-optimized run crashes then it is likely that the compiler has not |
|
|
#include <stdio.h>
|
|
|
int main()
|
|
|
{
|
|
|
printf ("Hello World!\
|
|
|
");
|
|
|
printf ("Hello World!\n");
|
|
|
}
|
|
|
```
|
|
|
|
|
|
Compile `hello.cpp` and run it. If this crashes your compiler is broken. Talk to your system administrator.
|
|
|
Compile `hello.cpp` and run it. Here is an example using g++:
|
|
|
```
|
|
|
g++ hello.cpp
|
|
|
./a.out
|
|
|
```
|
|
|
It should output `Hello World!` and stop. If this crashes your compiler is broken. Talk to your system administrator.
|
|
|
|
|
|
-----
|
|
|
|
... | ... | @@ -74,11 +78,11 @@ crash assert |
|
|
|
|
|
This uses the *crash* command, which is implemented in routine `ParseCrashDo`, to confirm that the code will crash on division by zero, overflow, use of NaN, the ASSERT macro used for internal code consistency checks, and array bounds checking.
|
|
|
|
|
|
In some compilers the routine `ParseCrashDo` will not work properly unless it is compiled without optimization since the compiler may detect that the results of the unsafe code are not used elsewhere in Cloudy, and simply not do the evaluation. With icc and the native SGI compiler you need to explicitly include the -O0 command line option to achieve this since optimization is the default. This could also apply to other compilers that we haven't tested. This is only to confirm that the crash will occur with the crash command, with these compilers safe code (code that will crash after a floating point error) is still produced with higher optimization, but the crash command itself will be optimized away.
|
|
|
In some compilers, the routine `ParseCrashDo` will not work properly unless it is compiled without optimization since the compiler may detect that the results of the unsafe code are not used elsewhere in Cloudy, and simply not do the evaluation. With ICC and the native SGI compiler, you need to explicitly include the -O0 command-line option to achieve this since optimization is the default. This could also apply to other compilers that we haven't tested. This is only to confirm that the crash will occur with the crash command, with these compilers safe code (code that will crash after a floating-point error) is still produced with higher optimization, but the crash command itself will be optimized away.
|
|
|
|
|
|
Crash assert is a special case. It might only fail when the code is compiled in debug mode since asserts may not exist in optimized code. If the code is compiled correctly and the asserts are working, then the calculation will end with statements saying that something bad has happened. This is the normal termination for a crash due to a failed assert and means that everything is fine.
|
|
|
|
|
|
If the code does not crash on each of these tests then your system is quite happy with bad floating point math or failed asserts. It is quite possible that you will not be able to get your system to crash on floating point errors. (This seems to get harder every year.) This is not a major problem but is something that should be kept in mind.
|
|
|
If the code does not crash on each of these tests then your system is quite happy with bad floating-point math or failed asserts. It is quite possible that you will not be able to get your system to crash on floating-point errors. (This seems to get harder every year.) This is not a major problem but is something that should be kept in mind.
|
|
|
|
|
|
------
|
|
|
|
... | ... | |