Opened 9 years ago

Closed 9 years ago

#5779 closed defect (fixed)

cast to 'void *' from smaller integer type 'int'

Reported by: Kurt Schwehr Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: svn-trunk
Severity: normal Keywords:
Cc:

Description

Not sure how to fix this one that I'm seeing on mac osx. Related to cleanup tracked in #5414

bin/sh /Users/schwehr/src/gdal/gdal/libtool --mode=compile --tag=CXX g++ -Wall -Wextra -Werror -I/Users/schwehr/src/gdal/gdal/port -I/Users/schwehr/src/gdal/gdal/gcore -I/Users/schwehr/src/gdal/gdal/alg -I/Users/schwehr/src/gdal/gdal/ogr -I/Users/schwehr/src/gdal/gdal/ogr/ogrsf_frmts -g -O2  -Wall  -I/sw -I/sw/include -I/sw/include -DOGR_ENABLED -I/sw/include -I/Users/schwehr/src/gdal/gdal/port -I/sw -I/sw/include -I/sw/include -I/sw -I/sw/include -I/sw -I/sw/include -I/sw/include -I/sw -I/sw/include -I/sw -I/sw/include -I/sw -I/sw/include  -DGDAL_COMPILATION -c -o ../o/ogdidataset.lo ogdidataset.cpp
libtool: compile:  g++ -Wall -Wextra -Werror -I/Users/schwehr/src/gdal/gdal/port -I/Users/schwehr/src/gdal/gdal/gcore -I/Users/schwehr/src/gdal/gdal/alg -I/Users/schwehr/src/gdal/gdal/ogr -I/Users/schwehr/src/gdal/gdal/ogr/ogrsf_frmts -g -O2 -Wall -I/sw -I/sw/include -I/sw/include -DOGR_ENABLED -I/sw/include -I/Users/schwehr/src/gdal/gdal/port -I/sw -I/sw/include -I/sw/include -I/sw -I/sw/include -I/sw -I/sw/include -I/sw/include -I/sw -I/sw/include -I/sw -I/sw/include -I/sw -I/sw/include -DGDAL_COMPILATION -c ogdidataset.cpp  -fno-common -DPIC -o ../o/.libs/ogdidataset.o
ogdidataset.cpp:963:16: error: cast to 'void *' from smaller integer type 'int' [-Werror,-Wint-to-void-pointer-cast]
        return (void *) nClientID;
               ^
1 error generated.
make[2]: *** [../o/ogdidataset.lo] Error 1
make[1]: *** [ogdi-install-obj] Error 2
make: *** [frmts-target] Error 2

Change History (4)

comment:1 by Even Rouault, 9 years ago

Perhaps (void*)(GPtrDiff_t)nClientId ?

comment:2 by Kurt Schwehr, 9 years ago

I'm wondering how this even works. On a 64 bit mac, I get

sizeof (void*): 8
sizeof int: 4

So isn't this asking for trouble / possible crash?

comment:3 by Even Rouault, 9 years ago

This code is a bit odd (but a void* can certainly host a int on all architectures on which GDAL can be compiled), and certainly unused by anyone, so you could just remove the GetInternalHandle() implementation as well if you prefer.

comment:4 by Kurt Schwehr, 9 years ago

Resolution: fixed
Status: newclosed

r28216 removes OGDIDataset::GetInternalHandle from trunk

Note: See TracTickets for help on using tickets.