public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/59354] New: Unexpected result in g++ when casting int to char from an stl vector to an array
@ 2013-11-30 14:25 jori.liesenborgs at gmail dot com
  2015-01-01 13:54 ` [Bug c++/59354] " gcc-bugzilla at contacts dot eelis.net
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: jori.liesenborgs at gmail dot com @ 2013-11-30 14:25 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59354

            Bug ID: 59354
           Summary: Unexpected result in g++ when casting int to char from
                    an stl vector to an array
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jori.liesenborgs at gmail dot com

Created attachment 31339
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31339&action=edit
test code

In the test code, the integer values from sixteen 4x4 blocks (in an stl vector)
are copied into an unsigned char array for 64x4 values. Using just -O3 this
appears to produce an incorrect result.

Some remarks:
 - Adding -mno-sse again yields the right output.
 - If the vector is replaced by a simple array, the correct result is
generated.
 - For 'xBlocks' less than 16, the correct result is also generated

To generate and run the executable:
g++ -O3 -o test test.ii
./test

Generated output (all four lines should actually be the same):
aaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbccccccccccccccccdddddddddddddddd
aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnoooopppp
aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnoooopppp
aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnoooopppp

GCC version info:
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-slackware-linux/4.8.2/lto-wrapper
Target: x86_64-slackware-linux
Configured with: ../gcc-4.8.2/configure --prefix=/usr --libdir=/usr/lib64
--mandir=/usr/man --infodir=/usr/info --enable-shared --enable-bootstrap
--enable-languages=ada,c,c++,fortran,go,java,lto,objc --enable-threads=posix
--enable-checking=release --enable-objc-gc --with-system-zlib
--with-python-dir=/lib64/python2.7/site-packages --disable-libunwind-exceptions
--enable-__cxa_atexit --enable-libssp --enable-lto --with-gnu-ld --verbose
--enable-java-home --with-java-home=/usr/lib64/jvm/jre
--with-jvm-root-dir=/usr/lib64/jvm
--with-jvm-jar-dir=/usr/lib64/jvm/jvm-exports --with-arch-directory=amd64
--with-antlr-jar=/tmp/gcc/antlr-runtime-3.4.jar --enable-java-awt=gtk
--disable-gtktest --disable-multilib --target=x86_64-slackware-linux
--build=x86_64-slackware-linux --host=x86_64-slackware-linux
Thread model: posix
gcc version 4.8.2 (GCC)

Test system was an 8 core slackware 14.0 system, with a /proc/cpuinfo content
like this:
processor    : 0
vendor_id    : GenuineIntel
cpu family    : 6
model        : 58
model name    : Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
stepping    : 9
microcode    : 0x17
cpu MHz        : 2550.000
cache size    : 8192 KB
physical id    : 0
siblings    : 8
core id        : 0
cpu cores    : 4
apicid        : 0
initial apicid    : 0
fpu        : yes
fpu_exception    : yes
cpuid level    : 13
wp        : yes
flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov
pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm
constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc
aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3
cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave
avx f16c rdrand lahf_lm ida arat epb xsaveopt pln pts dtherm tpr_shadow vnmi
flexpriority ept vpid fsgsbase smep erms
bogomips    : 6784.34
clflush size    : 64
cache_alignment    : 64
address sizes    : 36 bits physical, 48 bits virtual
power management:


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-06-23  8:46 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-30 14:25 [Bug c++/59354] New: Unexpected result in g++ when casting int to char from an stl vector to an array jori.liesenborgs at gmail dot com
2015-01-01 13:54 ` [Bug c++/59354] " gcc-bugzilla at contacts dot eelis.net
2015-01-07 20:30 ` [Bug middle-end/59354] " ville.voutilainen at gmail dot com
2015-01-08 11:04 ` [Bug tree-optimization/59354] Element swizzling produces invalid result with -O3 (tree-cunrolli pass problem?) ubizjak at gmail dot com
2015-01-08 14:52 ` [Bug tree-optimization/59354] [4.8/4.9/5/Regression] " hjl.tools at gmail dot com
2015-01-08 14:54 ` jakub at gcc dot gnu.org
2015-01-08 14:59 ` hjl.tools at gmail dot com
2015-01-14  7:02 ` [Bug tree-optimization/59354] [4.8/4.9/5/Regression] Element swizzling produces invalid result with -O3 ubizjak at gmail dot com
2015-01-14  8:52 ` [Bug tree-optimization/59354] [4.8/4.9/5 Regression] " rguenth at gcc dot gnu.org
2015-01-14  8:57 ` jakub at gcc dot gnu.org
2015-01-14  8:59 ` ville.voutilainen at gmail dot com
2015-01-14  9:47 ` rguenther at suse dot de
2015-01-14 14:06 ` rguenth at gcc dot gnu.org
2015-01-14 14:09 ` [Bug tree-optimization/59354] [4.8/4.9 " rguenth at gcc dot gnu.org
2015-02-23 12:19 ` rguenth at gcc dot gnu.org
2015-06-23  8:46 ` [Bug tree-optimization/59354] [4.8 " rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).