User account creation filtered due to spam.
Our HDF5 software has been having some data conversion problem with GCC's optimization for a few years. One example is to convert data from short to int. You can find the program at
When I use "gcc -O2" or "gcc -O3" to compile it, I get wrong values after the conversion. When I use "gcc -O0" or "gcc -O1", the values are correct.
I'll greatly appreciate your help if you can have a look at it.
You are violating C/C++ aliasing rules:
d = (uint8_t*)&aligned;
/* This line causes the trouble. */
*((int*)d) = (int)(*((short*)s));
You are writing into a long long via an int which causes undefined behavior.
There are more aliasing problems in this file too with the loop at:
As those are accessing an char via a short or an int.
*** This bug has been marked as a duplicate of 21920 ***