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

Adrian Thurston thurston at colm.net
Tue Jan 22 03:38:43 UTC 2019


Thanks for the report Ralf. Part of a push of work that needs to be done 
on cross compilation and types before 7.0 final.

On 2019-01-13 13:42, Ralf Hoffmann wrote:
> 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
> 
> _______________________________________________
> ragel-users mailing list
> ragel-users at colm.net
> http://www.colm.net/cgi-bin/mailman/listinfo/ragel-users



More information about the ragel-users mailing list