Review Request 124883: Fix compilation of PsCommentLexer.cpp on platforms where char is unsigned

Tom Hall tahall256 at gmail.com
Mon Aug 31 12:25:42 BST 2015



> On Aug. 30, 2015, 11:57 p.m., Friedrich W. H. Kossebau wrote:
> > Indeed there might be more places where this could be a problem.
> > If only KDE CI also had builds for ARM :)
> > Do you have commit rights to KDE repos? Otherwise I could commit for you.

I don't have commit rights.

CI on ARM would be good, although it would rely on having a good testsuite to find such problems. For example, something like this:
```C
char c = -1;
printf("c is %d\n", c);
```
..will compile without any warnings, but if char is unsigned, prints, "c is 255". C/C++ is just too careless when it comes to implicit casting. I haven't looked at or run krita's tests recently, so I don't know how comprehensive they are. I will try to run them and see what I get.


- Tom


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/124883/#review84612
-----------------------------------------------------------


On Aug. 22, 2015, 7:53 p.m., Tom Hall wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/124883/
> -----------------------------------------------------------
> 
> (Updated Aug. 22, 2015, 7:53 p.m.)
> 
> 
> Review request for Calligra.
> 
> 
> Repository: calligra
> 
> 
> Description
> -------
> 
> The C standard defines char to be either signed char or unsigned char. In this case, the char is used to store negative values to signify categories of characters as well as actual characters. Therefore it must be a signed char and doesn't work on platforms where char is unsigned (e.g. ARM). In this specific case, compilation of the file fails with:
> > "error: narrowing conversion of '-127' from 'int' to 'char' inside { } [-Wnarrowing]".
> 
> There may be similar issues elsewhere where the char isn't inside initialiser braces, so it compiles successfully, but silently truncates or wraps the negative values.
> 
> 
> Diffs
> -----
> 
>   filters/karbon/eps/PsCommentLexer.cpp 6487df6 
> 
> Diff: https://git.reviewboard.kde.org/r/124883/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Tom Hall
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/calligra-devel/attachments/20150831/3f1eaff1/attachment.htm>


More information about the calligra-devel mailing list