Notes from C++ static analysis

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Jun 26 12:03:29 PDT 2013


On Wed, Jun 26, 2013 at 08:57:46PM +0200, Adam D. Ruppe wrote:
> On Wednesday, 26 June 2013 at 18:08:10 UTC, bearophile wrote:
> >In D this is one case similar to variable shadowing, that the
> >compiler doesn't help you with:
> >        this.z = z;
> 
> I'd argue that assigning something to itself is never useful.

Unless opAssign does something unusual.

But yeah, that's bad practice and the compiler should warn about it. The
reason it doesn't, though, IIRC is because of generic code, where it
would suck to have to special-case when two template arguments actually
alias the same thing.


T

-- 
People say I'm arrogant, and so I am!!


More information about the Digitalmars-d mailing list