|
Boost : |
From: Craig Henderson (cdm.henderson_at_[hidden])
Date: 2002-10-09 03:25:19
"Björn Karlsson" <Bjorn.Karlsson_at_[hidden]> wrote in message
news:3D8559AE95B4D611B02C0002557C6C8B048856_at_STH-EXCH...
[snip]
> I don't know either, but I'd like to stress the fact that there's nothing
> wrong with the existing code. A change should probably be made for a
> specific compiler (VC.NET), with a specific flag (/RTCc) set. It's only
then
> that the workaround is necessary. That is, if anything should be changed
at
> all.
>
>
> Finally, and it's none of my business - but I've got to ask: Why would you
> want to defer this check to runtime, as it's always known at compile time?
I
> was baffled to see that this compiler option even existed for a statically
> typed language.
This problem sent me off to the microsoft.public.dotnet.languages.vc
newsgroup to report and discuss the problem. There was a lot of resistence
to my posting a bug about this, here are some quotes I got in reply:
"The static_cast should suppress the check, since a cast is the programmer's
way of telling the compiler 'I know what I'm doing here' " prompted "People
writing casts (explicit or implicit) that throw out non-zero bits are
exactly what this check is destined to find. If you want to make your
intention clear you must and with a mask. I don't understand the efficiency
argument* since if the value is actually used in a larger register or memory
location, the compiler must mask off the bits anyway as the implementation
of the cast" from Ronald Laeremans, Visual C++ team
* The efficiency argument was with regard to the extra Bitwise AND as we
have discussed.
The Visual C++ Team have conceded on some of the finer usability aspects of
the feature that I raised, which are off topic here, but I doubt I have been
unable to persuade them that this is problem with the compiler that needs
fixing.
I am no longer convinced that this is a problem that should be fixed in the
Boost library either. It is a VC7 specific runtime error which in itself is
questionable. However, I think maybe it should be added to the docs for the
CRC library as a know compiler specific issue, and suggest the user turn off
the /RTCc compiler option. I, for one, will not be using it as a default
setting in the future.
Regards
-- Craig
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk