Hi, Il 04/02/19 23:31, Louis Botha ha scritto: > With out the fix the program prints: 1000 > 2000 : true > > With this fix described below the program prints: 1000 > 2000 : false
Yes, it seems there is an inconsistency between gcc and tcc, because if you compile the "outer" program with tcc, then everything works. If you do use gcc, then you can see the bug. It seems that gcc uses only the lowest byte to return a _Bool from a function (but, interestingly, it zero-extends it when passing as an argument): https://godbolt.org/z/qKHb_M System V ABI[1] seems to be rather laconic on this matter: "Booleans, when stored in a memory object, are stored as single byte objects the value of which is always 0 (false) or 1 (true). When stored in integer registers (except for passing as arguments), all 4 bytes of the register are significant; any nonzero value is considered true". [1] https://github.com/hjl-tools/x86-psABI/wiki/intel386-psABI-1.1.pdf I would personally interpret that gcc is wrong here, because the _Bool is being passed as return value, not as argument. However, it is probably easier that tcc conform to gcc than the other way around. There is also an old gcc bug on more or less the same matter[2], from which I understand that apparently the ABI used to be different in the past. [2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42324 Giovanni. -- Giovanni Mascellani <[email protected]> Postdoc researcher - Université Libre de Bruxelles
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Tinycc-devel mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/tinycc-devel
