Gennaro Prota <[EMAIL PROTECTED]> writes:

> On Tue, 14 Jan 2003 17:11:39 -0500, David Abrahams
> <[EMAIL PROTECTED]> wrote:
>
>>Gennaro Prota <[EMAIL PROTECTED]> writes:
>>> As I think you all know, if you have something like
>>>
>>>     enum e { e1 = 1u << 31 };
>>>
>>> then it simply "promotes" e1 to int instead of unsigned int. For
>>> instance this
>>>
>>>     enum e { e1 = 2147483648u };
>>>
>>>     #include <iostream>
>>>
>>>     int main() {
>>>         std::cout << e1 << '\n';
>>>     }
>>>
>>> outputs -2147483648. Applied to my code, where I have e.g.
>>
>>Are you sure the promotion doesn't happen when e1 is passed to the
>>streaming operator?
>
> I'm afraid I don't understand your question. Maybe you are asking
> whether the compiler is just favoring conversion over promotion? I
> don't think so. I think the problem is that they just consider int as
> the underlying type, always. The overall effect however is
> more-or-less the same than if they always converted to int. As a
> further example, this executes the if-branch:
>
>    if ( (e1 + 0) < 0)
>            std::cout << "Bad promotion...\n";

Right.  But does it print anything in this case?

     if (e1 < 0)
           std::cout << "whoops\n";

Then I'd be worried.

-- 
                       David Abrahams
   [EMAIL PROTECTED] * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to