[Bug preprocessor/78008] New: Forbid or document #pragma pack(0)
dhekir at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Oct 17 11:32:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78008
Bug ID: 78008
Summary: Forbid or document #pragma pack(0)
Product: gcc
Version: 5.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: preprocessor
Assignee: unassigned at gcc dot gnu.org
Reporter: dhekir at gmail dot com
Target Milestone: ---
The GCC online doc
(https://gcc.gnu.org/onlinedocs/gcc/Structure-Layout-Pragmas.html) says that
#pragma pack is supported for compatibility with MS compilers.
However, the MSVC doc (https://msdn.microsoft.com/en-us/library/2e70t5y1.aspx)
explicitly states that, for pack(n): "Valid values are 1, 2, 4, 8, and 16."
Indeed, writing #pragma pack(0) and compiling (with VS 2010, in my case)
results in a warning:
warning C4086: expected pragma parameter to be '1', '2', '4', '8', or '16'
On GCC (I tried 5.4.0, but it seems not to have changed in quite some time),
using #pragma pack(0) results in no warnings, even with -Wall.
I found very old discussions (around gcc 2.9.5) mentioning that pack(0) is
supposed to disable the effect of #pragma pack, however this is not documented.
If the intended behavior is the same as "#pragma pack()" (without arguments),
please document it. Otherwise, it would be best if GCC would report this
construction as a warning/error, or at least indicate in the documentation that
it should not be used.
More information about the Gcc-bugs
mailing list