C standard library functions div() or ldiv() produces incorrect answers when compiled with tcc
Bug #191452 reported by
Iain Murray
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
tcc (Ubuntu) |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: tcc
Both div and ldiv give spurious results when compiled with tcc. For example, the following program:
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv)
{
div_t ans = div(27, 10);
printf("quot = %d; rem = %d\n", ans.quot, ans.rem);
return 0;
}
This should (and does when compiled with gcc) print:
quot = 2; rem = 7
When compiling with tcc I get:
quot = 8; rem = 7
I am running gutsy and was using the tcc that ships with that. I also built and installed the version from hardy:
tcc 0.9.24~
Same results.
To post a comment you must log in.
The fork available at: www.landley. net/code/ tinycc/
http://
doesn't exhibit this bug.
(I don't know anything else about the differences between the versions, or the back-story regarding the fork.)