[Bug c++/40192] [4.4/4.5 Regression] Unable to use std::vector with typedef'd array types

2009-05-19 Thread jeff at schwabcenter dot com


--- Comment #5 from jeff at schwabcenter dot com  2009-05-19 16:36 ---
Whoa whoa whoa...  The behavior seemed correct before.  vectorfloat[4]
shouldn't even be legal.  Shouldn't the compiler to catch such a mistake?


-- 

jeff at schwabcenter dot com changed:

   What|Removed |Added

 CC||jeff at schwabcenter dot com


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



[Bug c++/40192] [4.4/4.5 Regression] Unable to use std::vector with typedef'd array types

2009-05-19 Thread paolo dot carlini at oracle dot com


--- Comment #6 from paolo dot carlini at oracle dot com  2009-05-19 16:42 
---
I think that, in any case, we cannot do anything wrong here: we are simply
restoring an implementation detail of the previous implementations, which, as a
side effect, allows to compile this specific kind of snippet. Indeed, other
implementations also swallow it. So, let's take the legal issues aside, and
move on. If you figure specific details telling it's illegal just add it, as a
note, but certainly diagnostic is not required.


-- 


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



[Bug c++/40192] [4.4/4.5 Regression] Unable to use std::vector with typedef'd array types

2009-05-19 Thread jeff at schwabcenter dot com


--- Comment #7 from jeff at schwabcenter dot com  2009-05-19 17:09 ---
I understand the desire for backward compatibility, but are the semantics
actually the same?  Are the vector values arrays, or do they decay to pointers?
 Section 23.1 says standard container elements have to be CopyConstructible and
assignable, but raw arrays are neither.

Is there at least some flag to re-enable the diagnostic?  If you're saying this
is a necessary evil for reasons of backward compatibility, then I understand,
but in my opinion, this is a step backward that will confuse newcomers like
Brian and hurt cross-compatibility.  Speaking strictly as a GCC user, I don't
see any reason to reduce the compiler's ability to deduce an obvious mistake
with ill-defined semantics.


-- 


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



[Bug c++/40192] [4.4/4.5 Regression] Unable to use std::vector with typedef'd array types

2009-05-19 Thread paolo dot carlini at oracle dot com


--- Comment #8 from paolo dot carlini at oracle dot com  2009-05-19 17:12 
---
This is not going to change again. We had this behaviour forever until 4.3.x
and all the major implementations outside GCC behave the same as GCC now (and
before the change of behavior).


-- 


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



[Bug c++/40192] [4.4/4.5 Regression] Unable to use std::vector with typedef'd array types

2009-05-19 Thread jeff at schwabcenter dot com


--- Comment #9 from jeff at schwabcenter dot com  2009-05-19 17:32 ---
OK.  Thanks for the explanation.  Are the semantics documented somewhere?


-- 


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



[Bug c++/40192] [4.4/4.5 Regression] Unable to use std::vector with typedef'd array types

2009-05-19 Thread paolo dot carlini at oracle dot com


--- Comment #10 from paolo dot carlini at oracle dot com  2009-05-19 17:38 
---
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.


-- 


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



[Bug c++/40192] [4.4/4.5 Regression] Unable to use std::vector with typedef'd array types

2009-05-19 Thread coleb at eyesopen dot com


--- 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 vectorfloat4, you can't do anything useful
with it. 

typedef float cl_float4[4] __attribute__((aligned(16)));

#include vector

int main()
{
  std::vectorcl_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 vectorfloat4 to be compilable, but eh, lesson
learned, stay away from array types in C++. 


-- 


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



[Bug c++/40192] [4.4/4.5 Regression] Unable to use std::vector with typedef'd array types

2009-05-19 Thread jeff at schwabcenter dot com


--- Comment #12 from jeff at schwabcenter dot com  2009-05-19 18:07 ---
What he said.  I'm perusing your patch, and I appreciate that you removed an
artificial restriction.  The right place to catch this is up front, in a
concept check, rather than in _Destroy; since I'm not about to add the check
myself, I'm hardly in a position to criticize.  The diagnostic did have the
nice property of catching a real, semantic error, though, and it seems a shame
to let a known error go unreported.


-- 


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



[Bug c++/40192] [4.4/4.5 Regression] Unable to use std::vector with typedef'd array types

2009-05-19 Thread paolo dot carlini at oracle dot com


--- Comment #13 from paolo dot carlini at oracle dot com  2009-05-19 18:19 
---
It's life, you know ;)


-- 


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



[Bug c++/40192] [4.4/4.5 Regression] Unable to use std::vector with typedef'd array types

2009-05-18 Thread paolo dot carlini at oracle dot com


--- Comment #1 from paolo dot carlini at oracle dot com  2009-05-18 22:34 
---
I'll fix it momentarily.


-- 

paolo dot carlini at oracle dot com changed:

   What|Removed |Added

 AssignedTo|unassigned at gcc dot gnu   |paolo dot carlini at oracle
   |dot org |dot com
 Status|UNCONFIRMED |ASSIGNED
 Ever Confirmed|0   |1
   Last reconfirmed|-00-00 00:00:00 |2009-05-18 22:34:29
   date||
Summary|Unable to use std::vector   |[4.4/4.5 Regression] Unable
   |with typedef'd array types  |to use std::vector with
   ||typedef'd array types
   Target Milestone|--- |4.4.1


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



[Bug c++/40192] [4.4/4.5 Regression] Unable to use std::vector with typedef'd array types

2009-05-18 Thread paolo at gcc dot gnu dot org


--- Comment #2 from paolo at gcc dot gnu dot org  2009-05-18 23:16 ---
Subject: Bug 40192

Author: paolo
Date: Mon May 18 23:16:20 2009
New Revision: 147680

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=147680
Log:
2009-05-18  Paolo Carlini  paolo.carl...@oracle.com

PR libstdc++/40192
* include/bits/stl_construct.h (struct _Destroy_aux): Add.
(_Destroy(_ForwardIterator, _ForwardIterator)): Use the latter.
* testsuite/23_containers/vector/40192.cc: New.


Added:
trunk/libstdc++-v3/testsuite/23_containers/vector/40192.cc
Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/include/bits/stl_construct.h


-- 


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



[Bug c++/40192] [4.4/4.5 Regression] Unable to use std::vector with typedef'd array types

2009-05-18 Thread paolo at gcc dot gnu dot org


--- Comment #3 from paolo at gcc dot gnu dot org  2009-05-18 23:17 ---
Subject: Bug 40192

Author: paolo
Date: Mon May 18 23:16:48 2009
New Revision: 147681

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=147681
Log:
2009-05-18  Paolo Carlini  paolo.carl...@oracle.com

PR libstdc++/40192
* include/bits/stl_construct.h (struct _Destroy_aux): Add.
(_Destroy(_ForwardIterator, _ForwardIterator)): Use the latter.
* testsuite/23_containers/vector/40192.cc: New.


Added:
   
branches/gcc-4_4-branch/libstdc++-v3/testsuite/23_containers/vector/40192.cc
Modified:
branches/gcc-4_4-branch/libstdc++-v3/ChangeLog
branches/gcc-4_4-branch/libstdc++-v3/include/bits/stl_construct.h


-- 


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



[Bug c++/40192] [4.4/4.5 Regression] Unable to use std::vector with typedef'd array types

2009-05-18 Thread paolo dot carlini at oracle dot com


--- Comment #4 from paolo dot carlini at oracle dot com  2009-05-18 23:18 
---
Fixed for 4.4.1.


-- 

paolo dot carlini at oracle dot com changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution||FIXED


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