public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/61813] New: __attribute__((__packed__)) does not pack struct containing uint16_t with uint32_t
@ 2014-07-15 15:25 steven.spark at gmail dot com
  2015-08-26 20:44 ` [Bug c/61813] " steve at sk2 dot org
  2022-01-10  8:16 ` [Bug target/61813] " pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: steven.spark at gmail dot com @ 2014-07-15 15:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61813

            Bug ID: 61813
           Summary: __attribute__((__packed__)) does not pack struct
                    containing uint16_t with uint32_t
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: steven.spark at gmail dot com

Created attachment 33125
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33125&action=edit
preprocessed bugreport_packed.c

Test case:
typedef struct __attribute__((__packed__)) {
    uint16_t a;        ///  2
    uint32_t b;     /// +4
    uint32_t c[8];  /// +4*8 = 38
} foo_t;

but the size of foo_t is 40 (instead of the 38 which it should be). (It does
not matter where I put the packed attribute.)


I'm using the latest released mingw to date (4.8.1 rev 5).
I'm compiling on Windows 7 x64 (with mingw).
GCC config:
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-4.8.1/configure --host=x86_64-w64-mingw32
--build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64
--with-sysroot=/tmp/x64-481-win32-seh-r5/mingw64 --enable-shared
--enable-static --disable-multilib
--enable-languages=ada,c,c++,fortran,objc,obj-c++,lto
--enable-libstdcxx-time=yes --enable-threads=win32 --enable-libgomp
--enable-lto --enable-graphite --enable-checking=release
--enable-fully-dynamic-string --enable-version-specific-runtime-libs
--disable-isl-version-check --disable-cloog-version-check
--disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap
--disable-rpath --disable-win32-registry --disable-nls --disable-werror
--disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona
--with-tune=core2 --with-libiconv --with-system-zlib
--with-gmp=/tmp/mingw-prereq/x86_64-w64-mingw32-static
--with-mpfr=/tmp/mingw-prereq/x86_64-w64-mingw32-static
--with-mpc=/tmp/mingw-prereq/x86_64-w64-mingw32-static
--with-isl=/tmp/mingw-prereq/x86_64-w64-mingw32-static
--with-cloog=/tmp/mingw-prereq/x86_64-w64-mingw32-static
--enable-cloog-backend=isl --with-pkgversion='rev5, Built by MinGW-W64 project'
--with-bugurl=http://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe
-I/tmp/x64-481-win32-seh-r5/libs/include -I/tmp/mingw-prereq/x64-zlib/include
-I/tmp/mingw-prereq/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe
-I/tmp/x64-481-win32-seh-r5/libs/include -I/tmp/mingw-prereq/x64-zlib/include
-I/tmp/mingw-prereq/x86_64-w64-mingw32-static/include' CPPFLAGS= LDFLAGS='-pipe
-L/tmp/x64-481-win32-seh-r5/libs/lib -L/tmp/mingw-prereq/x64-zlib/lib
-L/tmp/mingw-prereq/x86_64-w64-mingw32-static/lib
-L/tmp/x64-481-win32-seh-r5/mingw64/opt/lib '
Thread model: win32
gcc version 4.8.1 (rev5, Built by MinGW-W64 project) 

command line 
gcc bugreport_packed.c
or
gcc -v -save-temps  -Wall -Wextra bugreport_packed.c

complete comiler output:
Using built-in specs.
COLLECT_GCC=C:\MinGW\x64-4.8.1-win32-seh-rev5\mingw64\bin\gcc
COLLECT_LTO_WRAPPER=c:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/4.8.1/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-4.8.1/configure --host=x86_64-w64-mingw32
--build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64
--with-sysroot=/tmp/x64-481-win32-seh-r5/mingw64 --enable-shared
--enable-static --disable-multilib
--enable-languages=ada,c,c++,fortran,objc,obj-c++,lto
--enable-libstdcxx-time=yes --enable-threads=win32 --enable-libgomp
--enable-lto --enable-graphite --enable-checking=release
--enable-fully-dynamic-string --enable-version-specific-runtime-libs
--disable-isl-version-check --disable-cloog-version-check
--disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap
--disable-rpath --disable-win32-registry --disable-nls --disable-werror
--disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona
--with-tune=core2 --with-libiconv --with-system-zlib
--with-gmp=/tmp/mingw-prereq/x86_64-w64-mingw32-static
--with-mpfr=/tmp/mingw-prereq/x86_64-w64-mingw32-static
--with-mpc=/tmp/mingw-prereq/x86_64-w64-mingw32-static
--with-isl=/tmp/mingw-prereq/x86_64-w64-mingw32-static
--with-cloog=/tmp/mingw-prereq/x86_64-w64-mingw32-static
--enable-cloog-backend=isl --with-pkgversion='rev5, Built by MinGW-W64 project'
--with-bugurl=http://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe
-I/tmp/x64-481-win32-seh-r5/libs/include -I/tmp/mingw-prereq/x64-zlib/include
-I/tmp/mingw-prereq/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe
-I/tmp/x64-481-win32-seh-r5/libs/include -I/tmp/mingw-prereq/x64-zlib/include
-I/tmp/mingw-prereq/x86_64-w64-mingw32-static/include' CPPFLAGS= LDFLAGS='-pipe
-L/tmp/x64-481-win32-seh-r5/libs/lib -L/tmp/mingw-prereq/x64-zlib/lib
-L/tmp/mingw-prereq/x86_64-w64-mingw32-static/lib
-L/tmp/x64-481-win32-seh-r5/mingw64/opt/lib '
Thread model: win32
gcc version 4.8.1 (rev5, Built by MinGW-W64 project) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-mtune=core2'
'-march=nocona'

c:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/4.8.1/cc1.exe
-E -quiet -v -iprefix
c:\mingw\x64-4.8.1-win32-seh-rev5\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.8.1/
-U_REENTRANT bugreport_packed.c -mtune=core2 -march=nocona -Wall -Wextra
-fpch-preprocess -o bugreport_packed.i
ignoring duplicate directory
"c:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/4.8.1/include"
ignoring nonexistent directory
"C:/Temp/msys64/tmp/x64-481-win32-seh-r5/mingw64C:/Temp/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../include"
ignoring duplicate directory
"c:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/4.8.1/include-fixed"
ignoring duplicate directory
"c:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/include"
ignoring nonexistent directory
"C:/Temp/msys64/tmp/x64-481-win32-seh-r5/mingw64/mingw/include"
#include "..." search starts here:
#include <...> search starts here:

c:\mingw\x64-4.8.1-win32-seh-rev5\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.8.1/include

c:\mingw\x64-4.8.1-win32-seh-rev5\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.8.1/include-fixed

c:\mingw\x64-4.8.1-win32-seh-rev5\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-mtune=core2'
'-march=nocona'

c:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/4.8.1/cc1.exe
-fpreprocessed bugreport_packed.i -quiet -dumpbase bugreport_packed.c
-mtune=core2 -march=nocona -auxbase bugreport_packed -Wall -Wextra -version -o
bugreport_packed.s
GNU C (rev5, Built by MinGW-W64 project) version 4.8.1 (x86_64-w64-mingw32)
    compiled by GNU C version 4.8.1, GMP version 5.1.2, MPFR version 3.1.2, MPC
version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C (rev5, Built by MinGW-W64 project) version 4.8.1 (x86_64-w64-mingw32)
    compiled by GNU C version 4.8.1, GMP version 5.1.2, MPFR version 3.1.2, MPC
version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: b31b8d99d71c616db8d6053c2fc710b4
bugreport_packed.c: In function 'main':
bugreport_packed.c:16:5: warning: format '%d' expects argument of type 'int',
but argument 2 has type 'long long unsigned int' [-Wformat=]
     printf("Packet Size: %d\r\n", sizeof(foo_t));
     ^
bugreport_packed.c:12:14: warning: unused parameter 'argc' [-Wunused-parameter]
 int main(int argc, char **argv)
              ^
bugreport_packed.c:12:27: warning: unused parameter 'argv' [-Wunused-parameter]
 int main(int argc, char **argv)
                           ^
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-mtune=core2'
'-march=nocona'

c:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/as.exe
-v -o bugreport_packed.o bugreport_packed.s
GNU assembler version 2.23.2 (x86_64-w64-mingw32) using BFD version (GNU
Binutils) 2.23.2
COMPILER_PATH=c:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/4.8.1/;c:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/bin/../libexec/gcc/;c:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/
LIBRARY_PATH=c:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/;c:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/bin/../lib/gcc/;c:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/lib/../lib/;c:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../lib/;c:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/lib/;c:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-mtune=core2'
'-march=nocona'

c:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/4.8.1/collect2.exe
--sysroot=C:/Temp/msys64/tmp/x64-481-win32-seh-r5/mingw64 -m i386pep -Bdynamic
c:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o
c:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/lib/../lib/crtbegin.o
-Lc:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1
-Lc:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/bin/../lib/gcc
-Lc:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/lib/../lib
-Lc:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../lib
-Lc:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/lib
-Lc:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../..
bugreport_packed.o -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt
-ladvapi32 -lshell32 -luser32 -lkernel32 -liconv -lmingw32 -lgcc -lgcc_eh
-lmoldname -lmingwex -lmsvcrt
c:/mingw/x64-4.8.1-win32-seh-rev5/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/lib/../lib/crtend.o


Notes:
The same bug is produced with compiler version 4.7.3 (gcc version 4.7.3
(release with patches / build 20130526 by strawberryperl.com) )


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

* [Bug c/61813] __attribute__((__packed__)) does not pack struct containing uint16_t with uint32_t
  2014-07-15 15:25 [Bug c/61813] New: __attribute__((__packed__)) does not pack struct containing uint16_t with uint32_t steven.spark at gmail dot com
@ 2015-08-26 20:44 ` steve at sk2 dot org
  2022-01-10  8:16 ` [Bug target/61813] " pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: steve at sk2 dot org @ 2015-08-26 20:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61813

Stephen Kitt <steve at sk2 dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |steve at sk2 dot org

--- Comment #1 from Stephen Kitt <steve at sk2 dot org> ---
This appears to be a duplicate of
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54589 (__attribute__((packed))
doesn't work on mingw32 targets since ms-bitfields became the default).


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

* [Bug target/61813] __attribute__((__packed__)) does not pack struct containing uint16_t with uint32_t
  2014-07-15 15:25 [Bug c/61813] New: __attribute__((__packed__)) does not pack struct containing uint16_t with uint32_t steven.spark at gmail dot com
  2015-08-26 20:44 ` [Bug c/61813] " steve at sk2 dot org
@ 2022-01-10  8:16 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-10  8:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61813

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 52991.

*** This bug has been marked as a duplicate of bug 52991 ***

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

end of thread, other threads:[~2022-01-10  8:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-15 15:25 [Bug c/61813] New: __attribute__((__packed__)) does not pack struct containing uint16_t with uint32_t steven.spark at gmail dot com
2015-08-26 20:44 ` [Bug c/61813] " steve at sk2 dot org
2022-01-10  8:16 ` [Bug target/61813] " pinskia 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).