This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: c++/10332: Template classes are not instantiated correctly inpresense of #pragma pack()


The following reply was made to PR c++/10332; it has been noted by GNATS.

From: "Igor A. Goussarov" <igusarov at akella dot com>
To: Momchil Velikov <velco at fadata dot bg>
Cc: ljrittle at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org,
   nobody at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
Subject: Re: c++/10332: Template classes are not instantiated correctly in
 presense of #pragma pack()
Date: Mon, 14 Apr 2003 14:02:26 +0400

 Momchil Velikov wrote:
  >>>>>>"Igor" == Igor A Goussarov <igusarov at akella dot com> writes:
  >     Igor> Momchil Velikov wrote:
  >     >> What is the scope of #pragma pack ?
  >
  >     Igor>     Apparently, from the line it is encountered at till the 
 end of
  >     Igor> translation unit or till the next #pragma pack.
  >
  > In that case holding it in a global variable looks appropriate, no ?
 
     Up to a certain degree, yes. The concept of "packing" is applied to 
 structures, thus the packing size is a property of each structure. 
 Holding it in a global variable is justifiable only if there's 
 absolutely no chance that this variable could potentially be altered 
 before it is used to create an internal compiler representation of the 
 structure in question. I grant that C plain structures are 
 "instantiated" immediately at the point of their definition. C++ 
 templates are not.
     The compiler still have to store the last packing size in a global 
 var (or a stack, to support #pragma push/pop). But as soon as a struct 
 definition is encountered (whether a template or not), the value of that 
 global var should've been copied to that structure description. And the 
 compiler should later use the value from the structure description 
 rather then from the global var. In other words, the global var only 
 stores the current packing size and is used _solely_ to initialize the 
 packing size of each new defined struct.
     As Loren has mentioned, #pragma pack came from C compiler, and 
 probably its interference with C++ entities was not fully considered...
     By now, I'm most interested in figuring out the point of view of the 
 gcc developers: do you tend to think that the current interference of 
 #pragma pack and templates is an undocumented feature or an incorrect 
 behaviour?
 
 Best Regards,
 Igor
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]