sarah-walker-pcem / arculator

Arculator
http://b-em.bbcmicro.com/arculator
GNU General Public License v2.0
56 stars 23 forks source link

Compile error: cast from ‘void*’ to ‘int’ loses precision [-fpermissive] #10

Closed Sophira closed 2 years ago

Sophira commented 3 years ago

While compiling the current HEAD (17b63fda) on Linux, I receive an error while compiling wx-podule-config.cc (I've redacted the email address that showed up in the compile command):

make[1]: Entering directory '/opt/sophie/arculator-git/prog/src'
g++ -DPACKAGE_NAME=\"Arculator\" -DPACKAGE_TARNAME=\"arculator\" -DPACKAGE_VERSION=\"v2.0\" -DPACKAGE_STRING=\"Arculator\ v2.0\" -DPACKAGE_BUGREPORT=\"Sarah\ Walker\ \<email@redacted\>\" -DPACKAGE_URL=\"\" -DPACKAGE=\"arculator\" -DVERSION=\"v2.0\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_LIBZ=1 -DHAVE_LIBPTHREAD=1 -DHAVE_LIBOPENAL=1 -DHAVE_LIBASOUND=1 -I.    -I/usr/lib64/wx/include/gtk2-unicode-3.0 -I/usr/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -I/usr/include/SDL2 -D_REENTRANT -Wall -O0 -g -D_DEBUG -DDEBUG_LOG -MT arculator-wx-podule-config.o -MD -MP -MF .deps/arculator-wx-podule-config.Tpo -c -o arculator-wx-podule-config.o `test -f 'wx-podule-config.cc' || echo './'`wx-podule-config.cc
wx-podule-config.cc: In member function ‘void PoduleConfigDialog::OnCombo(wxCommandEvent&)’:
wx-podule-config.cc:351:77: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
  351 |                                         update = item->function(this, item, (void *)(dynamic_cast<wxComboBox *>(obj)->GetCurrentSelection()));
      |                                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
wx-podule-config.cc: In function ‘void* podule_config_get_current(void*, int)’:
wx-podule-config.cc:588:32: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
  588 |                         return (void *)cbox->GetSelection();
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
wx-podule-config.cc: In function ‘void podule_config_set_current(void*, int, void*)’:
wx-podule-config.cc:619:44: error: cast from ‘void*’ to ‘int’ loses precision [-fpermissive]
  619 |                         cbox->SetSelection((int)val);
      |                                            ^~~~~~~~
make[1]: *** [Makefile:1571: arculator-wx-podule-config.o] Error 1
make[1]: Leaving directory '/opt/sophie/arculator-git/prog/src'
make: *** [Makefile:400: all-recursive] Error 1

I was able to track the error down to commit 2cbbbe4c; I was able to compile its parent commit (bb21e9e1) successfully.

Relevant information:

Neelix57 commented 2 years ago

Got the same error compiling Arculator Master.

TomMettam commented 2 years ago

-fpermissive bypasses this issue, but it's a code smell and should be fixed

sarah-walker-pcem commented 2 years ago

Fixed in 5a8e717.