Jump to content
Sign in to follow this  
Guest Joe

Enums Dont Work As Expected In Bc1.9

Recommended Posts

Guest Joe

BUG #1: The last enum in the set will always be undefined:

 

enum enumDays { SUN, MON, TUE };  // last one is TUE
:
:
unsigned char  a = SUN;  // ok (but incompatable types)
unsigned int   b = MON;  // ok (but incompatable types)
unsigned short c = TUE;  // error (undefined)

 

 

 

enum enumDays { SUN, MON, TUE, WED };  // last one is WED
:
:
unsigned char  a = SUN;  // ok (but incompatable types)
unsigned int   b = MON;  // ok (but incompatable types)
unsigned short c = TUE;  // ok (but incompatable types)
unsigned char  d = WED;  // error (undefined)

 

 

BUG #2: Also note that type 'enum' appears to be incompatable with ALL other types, rendering it impossible to use enums.

 

Work-around, use:

 

#define SUN 0
#define MON 1
#define TUE 2

 

Also try this:

** NOTE ** This has been known to crash windowsXP.

enum enumDays { SUN, MON, TUE };
void foo()
{
 if(1 > TUE)
 {
   nop();
 }
}

 

This causes an access violation within the compiler <very bad>. SB should be closed and reopened if this occurs.

 

 

Joe

Share this post


Link to post
Share on other sites
BUG #1: The last enum in the set will always be undefined:

 

enum enumDays { SUN, MON, TUE };  // last one is TUE
:
:
unsigned char  a = SUN;  // ok (but incompatable types)
unsigned int   b = MON;  // ok (but incompatable types)
unsigned short c = TUE;  // error (undefined)

 

 

 

enum enumDays { SUN, MON, TUE, WED };  // last one is WED
:
:
unsigned char  a = SUN;  // ok (but incompatable types)
unsigned int   b = MON;  // ok (but incompatable types)
unsigned short c = TUE;  // ok (but incompatable types)
unsigned char  d = WED;  // error (undefined)

 

 

BUG #2: Also note that type 'enum' appears to be incompatable with ALL other types, rendering it impossible to use enums.

 

Work-around, use:

 

#define SUN 0
#define MON 1
#define TUE 2

 

Also try this:

** NOTE ** This has been known to crash windowsXP.

enum enumDays { SUN, MON, TUE };
void foo()
{
 if(1 > TUE)
 {
   nop();
 }
}

 

This causes an access violation within the compiler <very bad>. SB should be closed and reopened if this occurs.

 

 

Joe

 

Fixed in BoostC 1.9.2. Thanks for reporting.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...