This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/40192] [4.4/4.5 Regression] Unable to use std::vector with typedef'd array types
- From: "coleb at eyesopen dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 May 2009 17:57:53 -0000
- Subject: [Bug c++/40192] [4.4/4.5 Regression] Unable to use std::vector with typedef'd array types
- References: <bug-40192-17730@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #11 from coleb at eyesopen dot com 2009-05-19 17:57 -------
(In reply to comment #10)
> Look closely at the patch I committed, I changed *nothing* of the actual
> behavior of the containers. Thus the semantics is exactly the same as before,
> only, the destructor in not called explicitly anymore on such element type,
> because the destructor is trivial.
>
Yup, even though you can declare a vector<float4>, you can't do anything useful
with it.
typedef float cl_float4[4] __attribute__((aligned(16)));
#include <vector>
int main()
{
std::vector<cl_float4> vals(1);
cl_float4 a = {1.0f, 2.0f, 3.0f, 4.0f};
vals.push_back(a);
}
/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/stl_algobase.h:412:
error: ISO C++ forbids assignment of arrays
Does seem strange to allow vector<float4> to be compilable, but eh, lesson
learned, stay away from array types in C++.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40192