BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

__int64 bit fields broke

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++)
View previous topic :: View next topic  
Author Message
Valence
Guest





PostPosted: Tue Aug 09, 2005 9:50 pm    Post subject: __int64 bit fields broke Reply with quote



The following code results in an Access Violation in BCB 5,
and BCB 6 has internal compile error F1001.

//---------------------------------------------------------------------------
struct My_Struct { // this was done since the borland bug had no
workaround
union {
unsigned __int64 a64;
struct {
unsigned __int64 b:8; //8 bits
unsigned __int64 c:1; //1 bit
unsigned __int64 d:1; //1 bit
unsigned __int64 e:1; //1 bit
unsigned __int64 f:1; //1 bit
unsigned __int64 g:1; //1 bit
unsigned __int64 h:1; //1 bit
unsigned __int64 i:1; //1 bit
unsigned __int64 j:3; //3 bits
unsigned __int64 k:2; //2 bits
unsigned __int64 l:1; //1 bit
unsigned __int64 m:10; //10 bits
unsigned __int64 n:10; //10 bits
unsigned __int64 o:5; //5 bits
unsigned __int64 p:2; //2 bits
};
};
};
//---------------------------------------------------------------------------
void __fastcall TForm1::Button9Click(TObject *Sender) {
My_Struct cm;
__int64 a = 1;
cm.b=a; //8 bits
cm.c=a; //1 bit
cm.d=a; //1 bit
cm.e=a; //1 bit
cm.f=a; //1 bit
cm.g=a; //1 bit
cm.h=a; //1 bit
cm.i=a; //1 bit
cm.j=a; //3 bits
cm.k=a; //2 bits
cm.l=a; //1 bit
cm.m=a; //10 bits
cm.n=a; //10 bits
cm.o=a; //5 bits
cm.p=a; //2 bits
}


Back to top
Andrue Cope [TeamB]
Guest





PostPosted: Wed Aug 10, 2005 7:40 am    Post subject: Re: __int64 bit fields broke Reply with quote



Valence wrote:

Quote:
The following code results in an Access Violation in BCB 5,
and BCB 6 has internal compile error F1001.

FWIW my advice would be not to use bitfields in the first place. The
C++ standard leaves a great deal up to the implementor. That means they
are not very portable. Borland's have even changed between compiler
versions once.

It's more portable to use bit masks and the & and | operators.

--
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html

Back to top
Valence
Guest





PostPosted: Thu Aug 11, 2005 8:31 am    Post subject: Re: __int64 bit fields broke Reply with quote




"Andrue Cope [TeamB]" <no.spam (AT) not (DOT) a.valid.address> wrote

Quote:
The C++ standard leaves a great deal up to the implementor.

I wonder if someone who is beta testing can test to see if Borland has
chosen to implement AVs and/or compiler fatal errors as implementor features
of the next release specifically for bit fields?

I understand the portability issues; for people who plan to use products
other than Builder...

Thanks.



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Aug 11, 2005 5:13 pm    Post subject: Re: __int64 bit fields broke Reply with quote


"Valence" <notrust (AT) nobody (DOT) com> wrote


Quote:
I wonder if someone who is beta testing can test to see if Borland
has chosen to implement AVs and/or compiler fatal errors as
implementor features of the next release specifically for bit fields?

Even if someone did test that for you, they would not be able to tell you
the results. To do so would be a violation of the NDA agreement that all
beta testers sign with Borland. One of the conditions of being a tester is
that a tester cannot tell anyone that he/she is a tester. So to reveil
information about a test performed in a beta product would be admitting that
the person has the beta available to begin with.


Gambit



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.