templates that are instantiated within a #pragma pack(1) context, generate code as if they where defined with #pragma pack(1). The result is, that one can create instantiations (in other compile units) that place class member variables on different memory locations for the SAME template arguments. Thus leeding to obvious data corruption when accessing them from different compile units. Release: gcc 2.95.3 Environment: SuSE Linux 7.3 (Kernel 2.4.18) How-To-Repeat: Unpack Attachment. cd gcc_bug ./run.sh (compiles and runs example)
Fix: template instantiations should respect the #pragma pack-state of their definition. The current state when beeing instantiated should be irrelevant.
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed. Not sure what the right answer is, but it would certainly be beneficial if the pragma-pack thing would be considered at the point of declaration, not at the point of instantiation -- just like an attribute attached to the type.
Looks like we have a large number of these "top level" bugs where things apply at the top level when instantiating when they should not apply.
*** Bug 10332 has been marked as a duplicate of this bug. ***
*** Bug 16044 has been marked as a duplicate of this bug. ***
*** Bug 21560 has been marked as a duplicate of this bug. ***
*** Bug 34614 has been marked as a duplicate of this bug. ***
Subject: Bug 7046 Author: jason Date: Fri Nov 6 03:33:17 2009 New Revision: 153959 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153959 Log: PR c++/7046 * class.c (finish_struct): Store maximum_field_alignment in TYPE_PRECISION. * pt.c (instantiate_class_template): Set maximum_field_alignment. Added: trunk/gcc/testsuite/g++.dg/abi/pragma-pack1.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/class.c trunk/gcc/cp/pt.c trunk/gcc/testsuite/ChangeLog
Fixed for 4.5.
*** Bug 260998 has been marked as a duplicate of this bug. *** Seen from the domain http://volichat.com Page where seen: http://volichat.com/adult-chat-rooms Marked for reference. Resolved as fixed @bugzilla.