[Insight-developers] warning C4267 on VC7

Andy Cedilnik andy.cedilnik@kitware.com
19 Feb 2003 16:24:52 -0500


Hi Lydia,

I think disabling C4276 would be a wrong way to go. The right way is to
go through ITK and fixing all the places where warning happens. I know
that is just about everywhere, but ignoring this warning might lead into
trouble sometimes down the road.

In VTK, we fixed most of these places. Fortunately at that time VTK did
not use STL, so the only place where this happened was when using
strlen(x).

Now, the reason why it would be bad to ignore the warning is simple.
Right now you are using mostly 32 bit platforms. size_t and unsigned int
are the same. Once you switch to 64 bit platform, that is not the case
any more. So, you will have a std::vector with 2^32 elements, you will
ask it for size and you will get 0 or something.

By fixing the warnings to some meaningful solutions (for example use
size_t or std::vector<bla>::size_type or whatever), you can be at least
a little bit sure that your thing will not blowup when somebody tries on
a large dataset.

				Andy

On Wed, 2003-02-19 at 15:56, Lydia Ng wrote:
> I am starting to use VC7 on my main development machine and as you can
> see from the dashboard there are thousands of warnings. Most of them are
> C4276:
> 
> d:\lng\Insight\Insight\Code\Common\itkObjectStore.txx(154) : warning
> C4267: 'argument' : conversion from 'size_t' to 'unsigned int', possible
> loss of data
> 
> Interestingly there are no docs on C4276. It appears whenever you get
> the size of STL containers.  Another amusing thing is that any sample
> code from the MS support site using STL disable this warning.
> 
> Would it be okay if I disable this also for ITK?