C standard library functions div() or ldiv() produces incorrect answers when compiled with tcc

Bug #191452 reported by Iain Murray
4
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~cvs20070502-2
Same results.

Revision history for this message
Iain Murray (ubuntu-iainmurray) wrote :

The fork available at:
    http://www.landley.net/code/tinycc/
doesn't exhibit this bug.

(I don't know anything else about the differences between the versions, or the back-story regarding the fork.)

Revision history for this message
Rob Landley (rob-landley) wrote :

A very brief version of the back story is at the end of the tinycc README:
http://landley.net/hg/tinycc/file/tip/README

Most of the work that's gone into the upcoming tcc 0.9.24 release consisted of backporting things from my repository that predated the LGPLv2->GPLv2 license change:

http://lists.gnu.org/archive/html/tinycc-devel/2007-11/msg00018.html
http://lists.gnu.org/archive/html/tinycc-devel/2007-11/msg00046.html
http://lists.gnu.org/archive/html/tinycc-devel/2007-11/msg00067.html
http://lists.gnu.org/archive/html/tinycc-devel/2007-12/msg00040.html

(The main reason I didn't accept maintainership of the old project back when Fabrice offered it was I refuse to deal with a CVS repository in the 21st century. Fabrice was ok with a new project based on tcc using a different repository format, but wanted his old project to stay in the CVS repository. *Shrug*)

Revision history for this message
Daniel T Chen (crimsun) wrote :

No longer ships in Ubuntu as of intrepid.

Changed in tcc:
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.