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

Discussion in 'C++' started by tkirankumar@gmail.com, Sep 12, 2006.

  1. Guest

    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, 2006
    #1
    1. Advertising

  2. Jens Theisen Guest

    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
     
    Jens Theisen, Sep 12, 2006
    #2
    1. Advertising

  3. F.J.K. Guest

    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
     
    F.J.K., Sep 12, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sydex
    Replies:
    12
    Views:
    6,508
    Victor Bazarov
    Feb 17, 2005
  2. Ollej Reemt
    Replies:
    7
    Views:
    547
    Jack Klein
    Apr 22, 2005
  3. Stig Brautaset

    `void **' revisited: void *pop(void **root)

    Stig Brautaset, Oct 25, 2003, in forum: C Programming
    Replies:
    15
    Views:
    793
    The Real OS/2 Guy
    Oct 28, 2003
  4. Replies:
    5
    Views:
    842
    S.Tobias
    Jul 22, 2005
  5. philwozza
    Replies:
    3
    Views:
    3,537
    philwozza
    May 13, 2006
Loading...

Share This Page