[nem-bug] [Nemerle 0000701]: [0.9.3] Empty structs have $PLACE_HOLDER$ field

feedback at nemerle.org feedback at nemerle.org
Sun Jul 2 13:15:17 CEST 2006


A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=701> 
======================================================================
Reported By:                Snaury
Assigned To:                
======================================================================
Project:                    Nemerle
Issue ID:                   701
Category:                   Compiler
Reproducibility:            always
Severity:                   feature
Priority:                   normal
Status:                     new
======================================================================
Date Submitted:             07-01-2006 16:05 CEST
Last Modified:              07-02-2006 13:15 CEST
======================================================================
Summary:                    [0.9.3] Empty structs have $PLACE_HOLDER$ field
Description: 
The following code:

  public struct EmptyStruct { }

produces empty structure with the following IL:

.class public sequential ansi sealed beforefieldinit EmptyStruct
       extends [mscorlib]System.ValueType
{
  .pack 0
  .size 1
} // end of class EmptyStruct

Nemerle's generated structure has no the following IL:

.class public auto ansi sealed EmptyStruct
       extends [mscorlib]System.ValueType
{
  .field private specialname uint8 $PLACE_HOLDER$
} // end of class EmptyStruct


As you can see, they differ and Nemerle's IL has strange $PLACE_HOLDER$
field. If possible, it would be good if generated code would be without
this $PLACE_HOLDER$ field...
======================================================================

----------------------------------------------------------------------
 nazgul - 07-01-06 21:26 
----------------------------------------------------------------------
AFAIR as added this field to mimick the C# compiler. But maybe has changed
after .NET 1.1 or it was mono compiler's behaviour. It must be checked if
this is still needed.

----------------------------------------------------------------------
 nazgul - 07-02-06 12:56 
----------------------------------------------------------------------
After using a patch I get verification error for empty structs:

bash-3.00$ ../../tools/verify out.exe 

Microsoft (R) .NET Framework PE Verifier.  Version  2.0.50727.42
Copyright (c) Microsoft Corporation.  All rights reserved.

[MD]: Error: ClassLayout has parent TypeDef token=0x02000002 marked
AutoLayout. [token:0x00000001]
1 Error Verifying out.exe


I'm investigating the possible fix.

----------------------------------------------------------------------
 Snaury - 07-02-06 13:11 
----------------------------------------------------------------------
Seems like after that class needs to be marked Sequential. I don't yet know
how type lookup in compiler works, though, so I don't know how a
StructLayout custom attribute can be applied on that struct...

----------------------------------------------------------------------
 nazgul - 07-02-06 13:15 
----------------------------------------------------------------------
At the stage of emitting hierarchy by S.R.E we can just define this
attribute using  code similar to make_nemerle_variant_attribute  in
HierarchyEmitter.n

Issue History
Date Modified  Username       Field                    Change              
======================================================================
07-01-06 16:05 Snaury         New Issue                                    
07-01-06 20:30 Snaury         File Added: bug-placeholder.patch                 
  
07-01-06 21:26 nazgul         Note Added: 0001331                          
07-02-06 12:56 nazgul         Note Added: 0001334                          
07-02-06 13:11 Snaury         Note Added: 0001335                          
07-02-06 13:15 nazgul         Note Added: 0001336                          
======================================================================




More information about the bugs mailing list