This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [BUG] valarray_copy, with mask_array, libstdc++-v3
- From: Luke Kenneth Casson Leighton <lkcl at samba-tng dot org>
- To: Ben Elliston <bje at redhat dot com>
- Cc: gcc-help at gcc dot gnu dot org, pcormier at redhat dot com, gcc at gcc dot gnu dot org,libstdc++ at gcc dot gnu dot org
- Date: Sat, 6 Jul 2002 19:53:46 +0000
- Subject: Re: [BUG] valarray_copy, with mask_array, libstdc++-v3
- References: <20020703220138.GC10352@samba-tng.org> <15652.33695.163590.836090@tooth.toronto.redhat.com>
On Thu, Jul 04, 2002 at 01:19:27PM -0400, Ben Elliston wrote:
> >>>>> "Luke" == Luke Kenneth Casson Leighton <lkcl@samba-tng.org> writes:
>
> Luke> valarray<bool> b(4);
> Luke> b[0] = false;
> Luke> b[1] = true;
> Luke> b[2] = true;
> Luke> b[0] = false;
>
> Luke> valarray<int> i(4);
> Luke> valarray<int> j;
i should point out that, in order to stop you getting confused,
this example is best modified to:
valarray<int> j(4);
however, whether the valarray is initially declared or not
has absolutely nothing to do with the bug.
to make the example even clearer to you, please try to compile
the example like this, instead:
valarray<int> j(i[b]);
and please, this time, actually _do_ bother to compile example
code that i send you, rather than wasting my time.
again.
l.
> Luke> i = 9;
>
> Luke> j = i[b];
>
> Luke> should create an array (j) of two items.
>
> Luke> instead, it overwrites memory and corrupts things
> Luke> because... well... here's a patch :)
>
> In Section 22.4.2 of The C++ Programming Language (3rd edition):
>
> ``A valarray can be assigned to another of the same size. As one
> would expect, v1 = v2 copies every element of v2 into its
> corresponding position in v1. If valarrays have different sizes,
> the result of assignment is undefined. Because valarray is designed
> to be optimised for speed, it would be unwise to assume that
> assigning with a valarray of the wrong size would cause an easily
> comprehensible error (such as an exception) or other "reasonable"
> behaviour.''
>
> Ben
--
----------------------------------------------------------
this message is private, confidential, and is intented for
the specified recipients only. if you received in error,
altered, deleted, modified, destroyed or interfered with
the contents of this message, in whole or in part, please
inform the sender (that's me), immediately.
if you, the recipient, reply to this message, and do not
then receive a response, please consider your reply to have
been lost or deliberately destroyed: i *always* acknowledge
personal email received. please therefore take appropriate
action and use appropriate protocols to ensure effective
communication.
thank you.