By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,978 Members | 1,362 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,978 IT Pros & Developers. It's quick & easy.

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

P: n/a
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...

Sep 12 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
tk*********@gmail.com writes:
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
Sep 12 '06 #2

P: n/a
tk*********@gmail.com wrote:
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

Sep 12 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.