g++ compilation - invalid conversion from void* to double*

T

tkirankumar

Hi all,

uname -a
SunOS cbmrsd1a1 5.10 Generic_118833-17 sun4us sparc FJSV,GPUZC-M

g++ -v
Reading specs from
/usr/local/lib/gcc-lib/sparc-sun-solaris2.10/3.3.2/specs
Configured with: ../configure --with-as=/usr/ccs/bin/as
--with-ld=/usr/ccs/bin/ld --disable-nls
Thread model: posix
gcc version 3.3.2

With 32 bit compilation, I compiled my application code successfully -
But I got the following errors when I tried 64-bit compilation by
giving options (-m64, -mcpu=v9) -

/usr/local/bin/g++ -m64 -mcpu=v9 -c -o PVA/PVA_ValueTable.o
PVA/PVA_ValueTable.cpp

/usr/local/include/c++/3.3.2/bits/stl_vector.h: In member function
`_Tp*
std::_Vector_alloc_base<_Tp, _Allocator, _IsStatic>::_M_allocate(long
unsigned int) [with _Tp = double, _Allocator = EFL_Allocator<double>,
bool
_IsStatic = false]':
/usr/local/include/c++/3.3.2/bits/vector.tcc:236: instantiated from
`void std::vector<_Tp, _Alloc>::_M_insert_aux(__gnu_cxx:
:__normal_iterator<_Tp*, std::vector<_Tp, _Alloc> >, const _Tp&) [with
_Tp = double, _Alloc = EFL_Allocator<double>]'
/usr/local/include/c++/3.3.2/bits/stl_vector.h:603: instantiated from
`void std::vector<_Tp, _Alloc>::push_back(const _Tp&)
[with _Tp = double, _Alloc = EFL_Allocator<double>]'
/export/home/edge/EDGE/edge/src/ETP/EVS/PVA/PVA_ValueTableColumnImpl.h:779:
instantiated from `void PVA_ValueTableColumnImpl
<T>::add(T) [with T = double]'
/export/home/edge/EDGE/edge/src/ETP/EVS/PVA/PVA_ValueTableColumnImpl.h:1231:
instantiated from here
/usr/local/include/c++/3.3.2/bits/stl_vector.h:97: error: invalid
conversion
from `void*' to `double*'


/usr/local/include/c++/3.3.2/bits/stl_vector.h: In member function
`_Tp*
std::_Vector_alloc_base<_Tp, _Allocator, _IsStatic>::_M_allocate(long
unsigned int) [with _Tp = float, _Allocator = EFL_Allocator<float>,
bool
_IsStatic = false]':
/usr/local/include/c++/3.3.2/bits/vector.tcc:236: instantiated from
`void std::vector<_Tp, _Alloc>::_M_insert_aux(__gnu_cxx:
:__normal_iterator<_Tp*, std::vector<_Tp, _Alloc> >, const _Tp&) [with
_Tp = float, _Alloc = EFL_Allocator<float>]'
/usr/local/include/c++/3.3.2/bits/stl_vector.h:603: instantiated from
`void std::vector<_Tp, _Alloc>::push_back(const _Tp&)
[with _Tp = float, _Alloc = EFL_Allocator<float>]'
/export/home/edge/EDGE/edge/src/ETP/EVS/PVA/PVA_ValueTableColumnImpl.h:779:
instantiated from `void PVA_ValueTableColumnImpl
<T>::add(T) [with T = float]'
/export/home/edge/EDGE/edge/src/ETP/EVS/PVA/PVA_ValueTableColumnImpl.h:1241:
instantiated from here
/usr/local/include/c++/3.3.2/bits/stl_vector.h:97: error: invalid
conversion
from `void*' to `float*'

But the same thing got compiled with 32 bit compilation. No clues, why
its failing to convert from void* to long*, double*, float*, short*
with
only 64 bit compilation...

Thanks in Advance...
 
J

Jens Theisen

But the same thing got compiled with 32 bit compilation. No clues, why
its failing to convert from void* to long*, double*, float*, short*
with
only 64 bit compilation...

At first, you need to show the code in question, since noone can tell
what line 97 of bits/stl_vector.hpp of your version of gcc is without
downloading it.

Then, this question is more suited for a gcc-secific group, since
c.l.c++ is more targetted to platform independent discussion.

Jens
 
F

F.J.K.

Hi all,

uname -a
SunOS cbmrsd1a1 5.10 Generic_118833-17 sun4us sparc FJSV,GPUZC-M

g++ -v
Reading specs from
/usr/local/lib/gcc-lib/sparc-sun-solaris2.10/3.3.2/specs
Configured with: ../configure --with-as=/usr/ccs/bin/as
--with-ld=/usr/ccs/bin/ld --disable-nls
Thread model: posix
gcc version 3.3.2

With 32 bit compilation, I compiled my application code successfully -
But I got the following errors when I tried 64-bit compilation by
giving options (-m64, -mcpu=v9) -

/usr/local/bin/g++ -m64 -mcpu=v9 -c -o PVA/PVA_ValueTable.o
PVA/PVA_ValueTable.cpp

/usr/local/include/c++/3.3.2/bits/stl_vector.h: In member function
`_Tp*
std::_Vector_alloc_base<_Tp, _Allocator, _IsStatic>::_M_allocate(long
unsigned int) [with _Tp = double, _Allocator = EFL_Allocator<double>,
bool
_IsStatic = false]':
/usr/local/include/c++/3.3.2/bits/vector.tcc:236: instantiated from
`void std::vector<_Tp, _Alloc>::_M_insert_aux(__gnu_cxx:
:__normal_iterator<_Tp*, std::vector<_Tp, _Alloc> >, const _Tp&) [with
_Tp = double, _Alloc = EFL_Allocator<double>]'
/usr/local/include/c++/3.3.2/bits/stl_vector.h:603: instantiated from
`void std::vector<_Tp, _Alloc>::push_back(const _Tp&)
[with _Tp = double, _Alloc = EFL_Allocator<double>]'
/export/home/edge/EDGE/edge/src/ETP/EVS/PVA/PVA_ValueTableColumnImpl.h:779:
instantiated from `void PVA_ValueTableColumnImpl
<T>::add(T) [with T = double]'
/export/home/edge/EDGE/edge/src/ETP/EVS/PVA/PVA_ValueTableColumnImpl.h:1231:
instantiated from here
/usr/local/include/c++/3.3.2/bits/stl_vector.h:97: error: invalid
conversion
from `void*' to `double*'


/usr/local/include/c++/3.3.2/bits/stl_vector.h: In member function
`_Tp*
std::_Vector_alloc_base<_Tp, _Allocator, _IsStatic>::_M_allocate(long
unsigned int) [with _Tp = float, _Allocator = EFL_Allocator<float>,
bool
_IsStatic = false]':
/usr/local/include/c++/3.3.2/bits/vector.tcc:236: instantiated from
`void std::vector<_Tp, _Alloc>::_M_insert_aux(__gnu_cxx:
:__normal_iterator<_Tp*, std::vector<_Tp, _Alloc> >, const _Tp&) [with
_Tp = float, _Alloc = EFL_Allocator<float>]'
/usr/local/include/c++/3.3.2/bits/stl_vector.h:603: instantiated from
`void std::vector<_Tp, _Alloc>::push_back(const _Tp&)
[with _Tp = float, _Alloc = EFL_Allocator<float>]'
/export/home/edge/EDGE/edge/src/ETP/EVS/PVA/PVA_ValueTableColumnImpl.h:779:
instantiated from `void PVA_ValueTableColumnImpl
<T>::add(T) [with T = float]'
/export/home/edge/EDGE/edge/src/ETP/EVS/PVA/PVA_ValueTableColumnImpl.h:1241:
instantiated from here
/usr/local/include/c++/3.3.2/bits/stl_vector.h:97: error: invalid
conversion
from `void*' to `float*'

But the same thing got compiled with 32 bit compilation. No clues, why
its failing to convert from void* to long*, double*, float*, short*
with
only 64 bit compilation...

Thanks in Advance...

For a guide on how to post on this newsgroup, please see point 5.8 of
Mashall Clines excellent FAQ:
http://www.parashift.com/c++-faq-lite/how-to-post.html

One requirement would be to send a complete and minimal testcase.
Something like:

int main() {
void *p;
double *d = p; // works in C, compile error in C++
}

int main() {
void *p;
double *d = (double *) p; // works for C and C++
}

It is possible, that this has to do with malloc and the grey area of
grateful incompatibilities between C/C++ , but this stuff is over my
head. Just do the "right thing" in the first place (which, according to
P.J. Plauger: http://www.thescripts.com/forum/post844763-55.html) is
using explicit casts, as given in my second example. In your case the
bug seems to be not in your own code, but in the library.

I thus think, you are in the wrong newsgroup, a more helpful place
would probably be http://gcc.gnu.org/ml/gcc-help/ as this seems to be a
bug with a very specific std library version of a very specific
compiler, that probably has been fixed for several years.

Yours, Felix
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top