Issue Details (XML | Word | Printable)

Key: PCC-384
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Anders Magnusson
Reporter: D C Gosnell
Votes: 0
Watchers: 0

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

Bug with bitshifting operation

Created: 23/Dec/11 03:47 PM   Updated: 24/Dec/11 12:03 PM
Component/s: i386 target
Affects Version/s: None
Fix Version/s: None

File Attachments: 1. File pccbug.c (0.1 kB)

Linux 2.6.31-21-generic-pae #59-Ubuntu SMP Wed Mar 24 08:47:55 UTC 2010 i686 GNU/Linux
pcc compiled with gcc 4.4.1

 Description  « Hide
The following program produces the output "IT'S 2", when I would expect "IT'S 0"

#include <stdio.h>

int main()
    int g = 0, b = 0, s = 0;
    long l = (g/2) | ((b/2)<<s);
    printf("IT'S %lx\n", l);

 All   Comments   Change History      Sort Order: Descending order - Click to sort in ascending order
Anders Magnusson added a comment - 24/Dec/11 12:03 PM
Fixed now, thanks for a good bug report!
The problem was that when an instruction with special needs (like left shift on i386 which requires the shift count in cl) but no explicit result register the register assigned by the register allocator was ignored.

Anders Magnusson added a comment - 23/Dec/11 05:37 PM
Yetch, this simple code fails on amd64 also. Hm...

D C Gosnell added a comment - 23/Dec/11 03:51 PM
I should have added the pcc version, which is :-

pcc 1.1.0.DEVEL 20111214 for i686-pc-linux-gnu