tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] Removing the horrible CString hack


From: Edmund Grimley Evans
Subject: [Tinycc-devel] Removing the horrible CString hack
Date: Sat, 21 Nov 2015 12:06:46 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

I have removed from TCC all the cases of illegal/undefined C that I
know about, apart from one, which is particularly horrible: the way a
CString is copied into a token string, which is an int array: see
tok_str_add2. On a 64-bit architecture the pointers end up misaligned,
so ASan gives lots of warnings. On a 64-bit architecture that required
memory accesses to be correctly aligned it would not work at all.

Here is a patch to cure the problem by putting the struct CString into
struct CValue instead. According to Valgrind, TCC does not leak memory
with this patch, though that's almost a miracle because it's very
unclear who is responsible for freeing the "data" in a string. Still,
unless someone has a better idea of how to do this, and is willing to
implement that better idea, I think this patch should go in. Opinions?

Edmund

Attachment: patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]