From -209429405833209023
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,7b33df5790e7ad92
X-Google-Attributes: gidf78e5,public
From: Gabriel Dos_Reis <gdosreis@korrigan.inria.fr>
Subject: Re: complex design flaw (#1)
Date: 1999/03/18
Message-ID: <xaj677zjxom.fsf@korrigan.inria.fr>#1/1
X-Deja-AN: 455996104
Content-Transfer-Encoding: 8bit
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <x88pv6fok3r.fsf@nbeckerpc.hns.com> <xaj3e3be4pu.fsf@korrigan.inria.fr> <01be6e30$aeae59e0$7d9cd4c7@danielp.interlog.com> <MPG.115705178a5dc0198994f@news.rmi.net> <01be6faa$cbf35d40$7d9cd4c7@danielp.interlog.com>
X-Original-Date: 18 Mar 1999 04:15:05 +0100
Content-Type: text/plain; charset=iso-8859-1
X-Complaints-To: news@news.unimelb.edu.au
X-Trace: izvestia.its.unimelb.edu.au 921733562 12659 128.250.29.17 (18 Mar 1999 05:06:02 GMT)
Organization: I.N.R.I.A Sophia-Antipolis (France)
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUANvCJpeEDnX0m9pzZAQElwgF/RO7sbcJQ87AB6h1VJMDFekXXH4TpP9wv 0d/809VG2fTa9P/C2qO7pQU0OVcimfy7 =g8j+
Mime-Version: 1.0
NNTP-Posting-Date: 18 Mar 1999 05:06:02 GMT
Newsgroups: comp.std.c++

"Daniel Parker" <danielp@no_spam.com> writes:

| Jerry Coffin <jcoffin@taeus.com> wrote in article
| <MPG.115705178a5dc0198994f@news.rmi.net>...
| > 
| > In article <01be6e30$aeae59e0$7d9cd4c7@danielp.interlog.com>, 
| > danielp@no_spam.com says...
| > 
| > > double x = 0.0;
| > > double y;
| > > 
| > > memset( &y, 0, sizeof(double) );
| > > 
| > > x == y ?
| > > memcmp( &x, &y, sizeof(double) ) == 0 ?
| > 
| > No, to both questions.  If you were restricting things to IEEE 
| > floating point, I _believe_ (though I'd have to do some looking to be 
| > sure) that setting all bits to zero will result in a value of zero.  
| 
| OK, but in the spirit of Gabriel Dos_Reis's post, would it be sensible
| (stupid?) to do the following.  In the system dependency library (that's
| the - hopefully small - one with all the #ifdef's) provide an
| implementation of an allocator such that if one were to write something
| like
| 
| SquareMatrix< std::complex<double> > A(10000);
| 
| on systems that supported IEEE, the allocation of the data would proceed as
| follows: allocate 10000*10000*sizeof(std::complex<double>) of raw memory,
| memset it to zero, and skip the step of calling placement new.

There is nothing wrong with it.
That is in essence what I was saying: an implementation is free to do
that optimization. In fact, I would expect amoderatly mature C++
implementation to  perform similar optimization.

-- 
Gabriel Dos Reis, dosreis@cmla.ens-cachan.fr
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]



