tgockel / json-voorhees

A killer modern C++ library for interacting with JSON.
http://tgockel.github.io/json-voorhees/
Apache License 2.0
128 stars 18 forks source link

parse: Cast `char`s to `unsigned char`s before doing bitwise operations. #110

Closed tgockel closed 6 years ago

tgockel commented 6 years ago

This casting should not be needed. However, GCC 8.1.0 seems to have a bug in the optimizer that causes this function to erroneously return true in some cases (specifically, char_bitmatch('\xf0', '\xc0', '\x20'), but not if you call the function directly). It is possible this issue (#108) has been misdiagnosed, but the behavior only happens on GCC 8.1.0 and only with -O3. The casting also fixes the problem, even though it logically should not change anything (https://stackoverflow.com/questions/50671485/bitwise-operations-on-signed-chars).

Will continue investigating potential GCC regressions, but this is probably okay for now.