This is the mail archive of the gcc-patches@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++ bootstrap (part 11/n): Add casts from void *


Andrew Pinski wrote:
> On Jul 25, 2004, at 6:32 PM, Bernardo Innocenti wrote:
> 
>>>If this is true then there is no way to use C++ to bootstrap
>>>as this will cause an old of range value from the enum which
>>>is undefined in C++ unless you change the definition of the
>>>current enum because it only goes one past the end of the
>>>generic trees.
>>
>>Uh?  I don't quite understand.  Do you mean that casting from
>>one enum type to another is undefined in C++ if the value
>>is out of range?
> 
> Yes, sorry for making a run-on-sentence. Well really enums are defined 
> to a certain range in C++ and anything outside of that range when
> casting to the enum is considered undefined.

I see...  But we're already silently mixing enum tree_code with
enum c_tree_code everywhere... adding casts can't make this
situation worse.  Or are short enums a C++-only thing?


> Note the behavior changed from 3.3.x to 3.4.x to be slightly different
> when it comes to casting.

Doesn't it just truncate the 16bit integer to an 8bit integer?


> Basically you add to the end of tree_code, 
> MAKE_SURE_THAT_THIS_CHAR_LENGTH = 0xFF;
> since we know that there is no way to use more than 255 tree codes
> (also all of the tree_code bit-fields are already 8 bits long).

How about adding a STATIC_ASSERT(LAST_AND_UNUSED_TREE_CODE < 0x100) ?
Some explanation would have to be given in a comment just above it.

-- 
  // Bernardo Innocenti - Develer S.r.l., R&D dept.
\X/  http://www.develer.com/


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