This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/59354] Unexpected result in g++ when casting int to char from an stl vector to an array
- From: "gcc-bugzilla at contacts dot eelis.net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 01 Jan 2015 13:54:12 +0000
- Subject: [Bug c++/59354] Unexpected result in g++ when casting int to char from an stl vector to an array
- Auto-submitted: auto-generated
- References: <bug-59354-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59354
Eelis <gcc-bugzilla at contacts dot eelis.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gcc-bugzilla at contacts dot eelis
| |.net
--- Comment #1 from Eelis <gcc-bugzilla at contacts dot eelis.net> ---
This is not specific to std::vector and not specific to C++.
C testcase:
#include <stdio.h>
#include <stdint.h>
int main()
{
uint32_t a[256] = {};
uint8_t b[1000] = {};
for(int i = 0; i != 256; ++i)
a[i] = i % 5;
for (int z = 0 ; z < 16; z++)
for (int y = 0 ; y < 4; y++)
for (int x = 0 ; x < 4; x++)
b[y * 64 + z*4 + x] = a[z * 16 + y * 4 + x];
printf("%d\n", b[4]);
return 0;
}
Prints '4' without -mno-sse, prints '1' with -mno-sse.