On 19.03.2010, at 14:22, MacArthur, Ian (SELEX GALILEO, UK) wrote:
> Something just struck me as odd about this.
>
> All these checks of the form:
>
>     if (sizeof(void *) == sizeof(<whatever>))
>
> The compiler must surely evaluate these statically at compile time, and
> the optimiser will surely be optimising away the invalid cases... So why
> are we getting the warning?

I don't know. I don't see the warning on my Ubuntu 9.04 with gcc 4.3.3
(although this emits many other warnings).

FWIW, on my Cygwin/gcc 3.4.4 I see:

Compiling Fl_Preferences.cxx...
Fl_Preferences.cxx:101:4: warning: #warning MSWindows implementation 
incomplete!
Fl_Preferences.cxx: In member function `void* 
Fl_Plugin_Manager::addPlugin(const char*, Fl_Plugin*)':
Fl_Preferences.cxx:1927: warning: cast from pointer to integer of 
different size

although I patched it with this patch:

Index: src/Fl_Preferences.cxx
===================================================================
--- src/Fl_Preferences.cxx      (revision 7302)
+++ src/Fl_Preferences.cxx      (working copy)
@@ -1923,9 +1923,9 @@
  #endif
    Fl_Preferences pin(this, name);
    // avoiding %p because it is not (fully) implemented on all machines
-  if (sizeof(void *) == sizeof(long long) )
+  if (sizeof(Fl_Plugin *) == sizeof(unsigned long long) )
      snprintf(buf, 31, "@%llx", (unsigned long long)plugin);
-  else if (sizeof(void *) == sizeof(long) )
+  else if (sizeof(Fl_Plugin *) == sizeof(unsigned long) )
      snprintf(buf, 31, "@%lx", (unsigned long)plugin);
    else
      snprintf(buf, 31, "@%x", (unsigned int)plugin);


Thus, the pointer *size* must equal the (unsigned) int size, and
the warning is wrong in the words "of different size" at least.

It's a cast to a different type anyway, but that shouldn't trigger
this warning IMHO, and it doesn't do with later gcc versions.

Here is the output (with the _original_ file) from Cygwin/gcc 4.3.4,
compiled in "X11" mode on Windows with the version before (!) Matt's
latest commit:

$ svnversion ; make
7302
Compiling Fl_Preferences.cxx...
Fl_Preferences.cxx:164:2: warning: #warning Unix implementation incomplete!
Fl_Preferences.cxx: In function 'char* decodeText(const char*)':
Fl_Preferences.cxx:685: warning: suggest explicit braces to avoid 
ambiguous 'else'
/usr/bin/ar cr ../lib/libfltk.a ...

No warning, same as on Linux. I think that we shouldn't bother
doing anything about such warnings. Although it is done now.

Albrecht
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to