Issue Details (XML | Word | Printable)

Key: PCC-434
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Iain Hibbert
Reporter: Iain Hibbert
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.

character constant is not sign extended correctly

Created: 27/May/14 10:28 PM   Updated: 28/May/14 10:32 PM
Component/s: C frontend, i386 target
Affects Version/s: None
Fix Version/s: None


 Description  « Hide
a character constant assigned to an integer is not sign extended correctly. the following code

#include <stdio.h>

int main(int ac, char *av[])
        int x = '\211';

        printf("x = %d\n", x);

        return 0;

when compiled and run, produces

% pcc test.c && ./a.out
x = 137

but it should be -119 ..

pcc-i386 is using signed-char on NetBSD, and the options are passed correctly (no -xuchar is passed to ccom)

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Iain Hibbert added a comment - 27/May/14 10:43 PM
PS this is described in note 13

Iain Hibbert added a comment - 28/May/14 09:38 AM
fixed this in esc2char. hex and octal escapes now take note of -xuchar

Antoine Leca added a comment - 28/May/14 06:28 PM
Unfortunately the fix proposed breaks the build of cpp (since it #includes <pass1.h>, which is unknown stuff within cpp.)

Iain Hibbert added a comment - 28/May/14 10:32 PM
I reworked the ucn support in cpp, so it does not need this file any longer