Hi,
The code below has no problem with GNU g++ 3.3,
but it has a problem with GNU g++ 3.4.
Any suggestions?
------ foo.cpp ------
#include <vector>
using namespace std;
typedef char foo_t[3];
#define ELEM1 "ab"
#define ELEM2 "cd"
const foo_t a[] = {ELEM1, ELEM2};
const vector<foo_t> v = vector<foo_t>(a , a + sizeof (a)/sizeof (*a));
int main()
{
return 0;
}
---------------------
------ Compilation with GNU gcc 3.3 (Cygwin) : BEGIN ------
$ g++ --version
g++ (GCC) 3.3.3 (cygwin special)
[---omitted---]
$ g++ -W -Wall foo.cpp
// No errors/warnings
------ Compilation with GNU gcc 3.3 (Cygwin) : END --------
------ Compilation with GNU gcc 3.4 (DJGPP) : BEGIN ------
$ gpp --version
gpp.exe (GCC) 3.4.1
[---omitted---]
$ gpp -W -Wall foo.cpp
c:/djgpp/bin/../lib/gcc/djgpp/3.41/../../../../include/cxx/3.41/bits/stl_construct.h : In function `void std::_Construct (_T1*, const
_T2&) [with _T1 = char[3], _T2 = char[3]]':
c:/djgpp/bin/../lib/gcc/djgpp/3.41/../../../../include/cxx/3.41/bits/stl_uninitializ ed.h:86: instantiated from `_ForwardIterat or
std::__uninitia lized_copy_aux( _InputIterator, _InputIterator, _ForwardIterato r, __false_type) [with _InputIterator =
__gnu_cxx::__no rmal_iterator<c onst char (*)[3], std::vector<cha r[3], std::allocator< char[3]> > >, _ForwardIterato r = char (*)[3]]'
c:/djgpp/bin/../lib/gcc/djgpp/3.41/../../../../include/cxx/3.41/bits/stl_uninitializ ed.h:112: instantiated from `_ForwardIterat or
std::uninitiali zed_copy(_Input Iterator, _InputIterator, _ForwardIterato r) [with _InputIterator = __gnu_cxx::__no rmal_iterator<c onst
char (*)[3], std::vector<cha r[3], std::allocator< char[3]> > >, _ForwardIterato r = char (*)[3]]'
c:/djgpp/bin/../lib/gcc/djgpp/3.41/../../../../include/cxx/3.41/bits/stl_vector.h:22 1: instantiated from `std::vector<_T p,
_Alloc>::vector (const std::vector<_Tp , _Alloc>&) [with _Tp = char[3], _Alloc = std::allocator< char[3]>]'
foo.cpp:9: instantiated from here
c:/djgpp/bin/../lib/gcc/djgpp/3.41/../../../../include/cxx/3.41/bits/stl_construct.h :81: error: ISO C++ forbids initialization in
array new
------ Compilation with GNU gcc 3.4 (DJGPP) : END --------
--
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn