On Mon, Nov 5, 2012 at 11:04 PM, Thomas Preud'homme <[email protected]> wrote: > Le lundi 5 novembre 2012 14:53:16, Hitoshi Mitake a écrit : >> Thanks, I committed the change on the mob branch. > > Great. > >> >> BTW, I've intended to implement comparison between structs >> originally. And I found the bug accidentally. > > As I reviewed your patch and realized it's correct and I was wrong ;) > >> >> Of course, comparison between different typed structs or structs and >> scalar typed values should cause compile error. But I feel that if we >> can write comparison between same struct typed values with == >> operator, a compiler will be very useful. Because we can avoid the >> possibility of passing wrong value as 3rd parameter of memcmp(). > > memcmp is not what you want because if a structure contains padding you are > not sure of its content. Therefore two structures could be identical with > different content inside the padding. You must compare field by field. That's > why > assignement is possible but not equality: assignment is ok because you can > copy the padding so memcpy will give a valid copy of the structure. Comparing > with memcpy on the other hand will return false for some equal structures.
Ah, I missed about the padding... As you say, memcmp() is not a stuff for the above situation. > >> >> The standard of C doesn't allow this behaviour. But I think it may be >> worth implementing it on TCC. Can TCC accept this behaviour as >> implementation specific dialect? > > From http://bellard.org/tcc/ : > > UNLIMITED! Any C dynamic library can be used directly. TCC is heading torward > full ISOC99 compliance. TCC can of course compile itself. > > I don't think we should not follow C99 on this. > OK, I understand the direction of TCC. I'll implement == for field by field comparison only for my toy if I'll do :) Thanks, -- Hitoshi Mitake [email protected] _______________________________________________ Tinycc-devel mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/tinycc-devel
