Ticket #12575 (closed build error: fixed)

Opened 3 years ago

Last modified 3 years ago

C++0x compilation error: narrowing conversions in xbm files.

Reported by: jan_van_dijk Owned by:
Priority: normal Milestone: 3.0
Component: wxGTK Version: 2.9-svn
Keywords: c+0x narrowing conversion, gdk, bitmap Cc:
Blocked By: Patch: yes
Blocking:

Description

gcc refuses to compile trunk/wxGTK in C++0x mode. The culprit is that in the .xbm files char-arrays are initialised with values >127. This does not fly if char==signed char, e.g:

../src/gtk/bdiag.xbm:6:50: error: narrowing conversion of ‘128’ from ‘int’ to ‘char’ inside { } [-fpermissive]

I admit that the REAL problem is upstream: gdk_bitmap_create_from_data should have expected unsigned char instead of char arguments. This has been noted in 2001, but was apparently never fixed, see for example

 http://markmail.org/message/7igyd4n7sw7g6lft

... so this observation is merely of theeoretical interest.

The attached patch reimplements the arrays as unsigned char ones, and uses a reinterpret_cast<const char*> in src/gtk/dcclient.cpp

Yes, this is ugly. If anybody has a better idea, please let me know and I will try to prepare and test an alternative patch. Otherwise, please consider this for inclusion. Thank you in advance.

Regards, Jan van Dijk.

Attachments

xbm.diff download (4.9 KB) - added by jan_van_dijk 3 years ago.
patch against r65839

Change History

Changed 3 years ago by jan_van_dijk

patch against r65839

follow-up: ↓ 2   Changed 3 years ago by vadz

  • keywords c+0x added
  • milestone set to 3.0

This is ugly but worse is that I'm not sure whether any XBM editors are going to be able to open the file after such modification. OTOH the only way to avoid changing the XBMs yet satisfy g++ that I see is to use an even uglier #define char unsigned char hack before including them and I'm not sure if it's worth it, these files are probably not edited that often.

in reply to: ↑ 1   Changed 3 years ago by jan_van_dijk

Replying to vadz:

This is ugly but worse is that I'm not sure whether any XBM editors are going to be able to open the file after such modification. OTOH the only way to avoid changing the XBMs yet satisfy g++ that I see is to use an even uglier #define char unsigned char hack before including them and I'm not sure if it's worth it, these files are probably not edited that often.

For what it's worth:

  Changed 3 years ago by vadz

  • status changed from new to confirmed

Ok, this definitely looks convincing, thanks for testing! Will apply the patch soon.

  Changed 3 years ago by VZ

  • status changed from confirmed to closed
  • resolution set to fixed

(In [65846]) Use unsigned char for XBM bitmaps data.

This fixes compilation with g++ in C++0x mode in which conversions of
constants not fitting into signed char range to char are not permitted.

Closes #12575.

Note: See TracTickets for help on using tickets.