https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80777
Bug ID: 80777 Summary: long int structure members allocated incorrect 8 bytes Product: gcc Version: 5.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: jrose.manila at gmail dot com Target Milestone: --- Created attachment 41363 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41363&action=edit source file describing bug Problem: long int structure members are allocated incorrect 8 bytes (as if long long), whereas retyping them with __uint32_t results in correct 4 bytes $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/lto-wrapper.exe Target: x86_64-pc-cygwin Configured with: /cygdrive/i/szsz/tmpp/gcc/gcc-5.4.0-1.x86_64/src/gcc-5.4.0/configure --srcdir=/cygdrive/i/szsz/tmpp/gcc/gcc-5.4.0-1.x86_64/src/gcc-5.4.0 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit --with-dwarf2 --with-tune=generic --enable-languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable-graphite --enable-threads=posix --enable-libatomic --enable-libcilkrts --enable-libgomp --enable-libitm --enable-libquadmath --enable-libquadmath-support --enable-libssp --enable-libada --enable-libgcj-sublibs --disable-java-awt --disable-symvers --with-ecj-jar=/usr/share/java/ecj.jar --with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible Thread model: posix gcc version 5.4.0 (GCC) running on cygwin64 for windows 10: $ uname -a CYGWIN_NT-10.0 Caroline-2 2.8.0(0.309/5/3) 2017-04-01 20:47 x86_64 Cygwin Source: gcc5.4.0.bug.c (attached) See definition of struct ProductId, members len, format, u.v3.edition.id How to test: 1. Edit ProductId structure members len, format declarations to either __uint32_t or unsigned long int 2. gcc -g -Wall -Wextra gcc5.4.0.bug.c -o gcc5.4.0.bug.exe 3. gdb ./gcc5.4.0.bug.exe b main b 142 run c n print *pId and you will see incorrect 8-byte values for pId->len and pId->format if you declare as unsigned long int, or you will see correct 4-byte values if you declare with __uint32_t Further tests within gdb: print sizeof(long int) print sizeof(pId->len) print sizeof(ii)