This is the mail archive of the gcc@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: Help with bit-field semantics in C and C++


On Wed, Aug 25, 2004 at 02:21:40AM +0200, Gabriel Dos Reis wrote:
> |  Is that a bug we must fix?
> 
> Yes, in as much as we're not allowed to crash.  The fix consists
> in projecting the value to the proper range -- this need doing only
> when the source value manifestly comes from non enum-value preserving
> operations or unknown sources.

Then we're screwed; C++ is doomed to be slower than C for a large number
of programs that I write, and all implementations are broken.

That is, I know of no compiler that, given

enum E { zero, one, two, three };

E foo;

void init_foo(int arg) {
     foo = (E)arg;
}

generates any kind of checking or masking to assure that foo does not
get an out-of-range value.


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