[ragel-users] compile issue on platforms with char being unsigned by default
ralf at boomerangsworld.de
Sun Jan 13 06:42:29 UTC 2019
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 18.104.22.168 (but 22.214.171.124 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
Ralf Hoffmann <ralf at boomerangsworld.de>
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 743 bytes
Desc: not available
More information about the ragel-users