Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-09-26 10:04:32


On Thursday 26 September 2002 03:51 am, Björn Karlsson wrote:
> Some time ago, Lars Gullik Bjønnes wrote this:
> >We get a lot of warnings with the
> >
> >char * ptr = 0;
> >assert(ptr);
> >
> >idom on 64 bit computers, in that a converson from 64bit integer to 32
> >bit integer can loose bits."
>
> The proposed solution was trivial: using assert(ptr!=0); removes the
> warning. This [assert(ptr)] is a fairly common construct, and as it seems
> to do no harm, and avoid annoying warnings, should we apply it Boost-wide?

The only forseeable problem is that 'ptr != 0' wouldn't be a valid expression
for some smart pointers, so while we can fix the code when we know we have a
raw pointer, we can't fix it if the pointer type is a template type
parameter.

I think we should just ban the use of raw pointers, and use raw_ptr<T>
instead. Problem solved :)

        Doug


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk