This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/13121] Inserting struct with valarray in map fails


------- Additional Comments From Uwe dot Seimet at seimet dot de  2003-11-19 15:00 -------
Subject: Re:  Inserting struct with valarray in map fails

Hello!

> ------- Additional Comments From bangerth at dealii dot org  2003-11-19 14:47 -------
> This is because this program
> ------------------
> #include <valarray>
> #include <iostream>
> 
> int main ()
> {
>   std::valarray <int> v1(5);
>   std::valarray <int> v2;
>   v2 = v1;
> 
>   std::cout << v1.size() << " " << v2.size() << std::endl;
> }
> -----------------------
> when compiled with any gcc version returns
>   g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ x.cc ; ./a.out
>   5 0
> 
> icc, for reference, returns "5 5". Both results are standards conforming,
> since 26.3.2.2/1 reads: "...The resulting behavior is undefined if the
> length of the argument array is not equal to the length of the *this
> array."
> 
> What you do with your map is the following: you first create an entry
> by using m[(void*)0], and only then do you assign to it, so the result
> is fully conforming.

Thank you for your rapid response! So gcc is obviously right, and our code
is wrong. Nevertheless we think that the standard is a bit strange, allowing
undefined behavior for an assignment.

Best regards,   Uwe



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13121


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]