Menu

#5 Strict-aliasing rules violations

closed-fixed
None
5
2009-10-08
2009-10-08
Marc Noirot
No

Compiling json.c and json.h 1.1 in GCC 4.2.4 causes a certain number of warnings related to type casts into (rcstring**).
While not a bug strictly-speaking, these rule violations might prevent your code from being properly optimized on certain platforms (see http://xania.org/200712/cpp-strict-aliasing\).

These warnings can be fixed by moving the rcstring declarations into json.h and by properly using rcstring* instead of void* in the json_parsing_info and json_saxy_parser_status structures.
This also allows the removal of every cast into rcstring* and rcstring** in the code.

I have patched json.c and json.h version 1.1 for use in my flvmeta project, the changed can be seen here : http://code.google.com/p/flvmeta/source/detail?r=131

Discussion

  • Anonymous

    Anonymous - 2009-10-08
    • assigned_to: nobody --> rui_maciel
    • status: open --> closed-fixed
     
  • Anonymous

    Anonymous - 2009-10-08

    First of all, thanks for taking the time to post a bug report and for passing on such an insightful tip. Nice stuff. I've just commited your changes to the trunk. Nonetheless, how much of a performance impact did the void * usage caused?

    On a side note, MJSON is currently being rewritten from scratch and, as it won't rely on rcstring-type constructs to deal with strings, it won't suffer from this kind of performance issues.

     

Log in to post a comment.