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: [c++] switch ( enum ) vs. default statment.


Paweł Sikora wrote:

>> On the other hand, if you are writing a portable library designed
>> to be used with other people's programs, you might every well want
>> the warning -- because you can't be sure that they're not going to
>> pass "7" in as the value of "e", and you may want to be robust in
>> the face of this *unspecified* behavior.
> 
> sorry, i don't care about unspecified/undefined behavior triggered
> by users glitches. it's not a problem of my library.

The point I was trying to make was that "unspecified" and "undefined"
are actually very different.  I wouldn't be too surprised if, in the
future, G++ defined the behavior of the "e = (E) 7" case as storing the
value in the underlying type.  Then, might indeed rely on that.

Obviously, you're free to make your own decisions, but, personally, I
would certainly feel free to assume that no undefined behavior happened
in the application -- but I wouldn't assume that no unspecified behavior
occurred.

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713


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