[ragel-users] compile issue on platforms with char being unsigned by default

Ralf Hoffmann ralf at boomerangsworld.de
Sun Jan 13 06:42:29 UTC 2019


Hi,

I got a report for a project of mine that compilation does not work on
platforms where the C type "char" is unsigned by default. The problem is
within a file generated with ragel 7.0.0.10 (but 7.0.0.11 behaves the same).

The array *trans_cond_spaces is of type const char[] but contains a lot
of -1. This will lead to a compiler error: narrowing conversion of ‘-1’
from ‘int’ to ‘char’ inside...

I have attached a small (stripped-down) example which does not do
anything useful but triggers the problem.

Steps to reproduce:

$ ragel test.rl -o test.cc
$ g++ -funsigned-char test.cc -c

g++ is 7.3.1.

I don't want to compile a selected file with "-fsigned-char"  and all
the rest with the default behavior so my current workaround is to patch
the array to be of type "signed char[]". Since this is the intended
behavior anyway may I suggest to change the generated output to use
signed char? I don't know if any of the other arrays may contain
negative values as well.

Feedback is very welcome, maybe there is also some other way around this
problem.

Best regards,

Ralf

-- 
Ralf Hoffmann <ralf at boomerangsworld.de>
Homepage: http://www.boomerangsworld.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.rl
Type: application/resource-lists+xml
Size: 743 bytes
Desc: not available
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20190113/0cb744b4/attachment.bin>


More information about the ragel-users mailing list