NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: misc/50754: src/sys/arch/epoc32/stand/e32boot/ldd/epoc32.cpp:62: shallow copy or deep copy ?
The following reply was made to PR misc/50754; it has been noted by GNATS.
From: David Holland <dholland-bugs%netbsd.org@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc:
Subject: Re: misc/50754: src/sys/arch/epoc32/stand/e32boot/ldd/epoc32.cpp:62:
shallow copy or deep copy ?
Date: Tue, 31 May 2016 02:23:55 +0000
On Wed, Feb 03, 2016 at 09:50:00AM +0000, dcb314%hotmail.com@localhost wrote:
> [src/sys/arch/epoc32/stand/e32boot/ldd/epoc32.cpp:62]: (style) Value of pointer 'cpu', which points to allocated memory, is copied in copy constructor instead of allocating new memory.
>
> For objects with pointers to other objects, it is usual to prefer
> deep copy to shallow copy.
Perhaps in CS101 style-checker land. In real programs, structure
members (er, pardon me, fields of objects) that point to things may be
part of the same object (in which case cloning them along with
everything else is usually the right thing) or references to external
objects (in which case cloning them willy-nilly is almost always
wrong) or, as appears to be the case this time, global references to
singletons, in which case copying them is certainly wrong.
This isn't up to the usual standards of your checker and your
reporting...
(also, 5 seconds of grepping shows that the offending copy constructor
is not used)
--
David A. Holland
dholland%netbsd.org@localhost
Home |
Main Index |
Thread Index |
Old Index