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 Tuesday, August 24, 2004, at 03:02 PM, David Carlton wrote:
I'm certainly not intending to be clever here.  I would say, actually,
that I'm trying to be as naive as possible in my reading.

That is in general dangerous.


I dunno. I ran this example:

enum Small { Zero = 0, One = 1, Two = 2, Three = 3 };

Small x = (Small) 7;

  switch ( x ) {
    case Zero:
      return zero();
    case One:
      return one();
    case Two:
      return two();
    case Three:
      return three();
  }

by a couple of people who walked by my cubicle, before showing them
the standard.  Their first reaction is that they would expect the
switch statement to fall through.

That doesn't surprise me.


When I showed them the standard, they agreed that it wouldn't fall through.

Then they misread the standard. The conversion is unspecified, there is nothing that prohibits it from having the value 7 and from the switch statement from falling through.


* Users would be disappointed if the above example were to, say, core
  dump (which is behavior that is being proposed in some messages on
  this thread).

Agreed.



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