Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCC 5.4.0 gives unexpected read errors #104

Open
lnkuiper opened this issue Jan 24, 2023 · 1 comment
Open

GCC 5.4.0 gives unexpected read errors #104

lnkuiper opened this issue Jan 24, 2023 · 1 comment
Labels
compability Compability for compiler or OS

Comments

@lnkuiper
Copy link

Describe the bug
I get YYJSON_READ_ERROR_UNEXPECTED_END when reading this (and other JSON):

{
    "firstName": "John",
    "lastName": "Smith",
    "isAlive": true,
    "age": 25,
    "address": {
      "streetAddress": "21 2nd Street",
      "city": "New York",
      "state": "NY",
      "postalCode": "10021-3100"
    },
    "phoneNumbers": [
      {
        "type": "home",
        "number": "212 555-1234"
      },
      {
        "type": "office",
        "number": "646 555-4567"
      }
    ],
    "children": [],
    "spouse": null
}

Your environment

  • OS: Ubuntu 16.04
  • Compiler: GCC 5.4.0

Additional context
I have changed some #defines and found that disabling this piece of code (e.g., by changing 4 to 6 so it is not triggered for GCC 5.4) solves the problem.

/** unlikely for compiler */
#ifndef yyjson_unlikely
#   if yyjson_has_builtin(__builtin_expect) || YYJSON_GCC_VER >= 4
#       define yyjson_unlikely(expr) __builtin_expect(!!(expr), 0)
#   else
#       define yyjson_unlikely(expr) (expr)
#   endif
#endif

It seems to work properly in our GCC 4.8 builds though, so maybe it's best to set it to:

YYJSON_GCC_VER >= 4 && YYJSON_GCC_VER != 5
@ibireme ibireme added the compability Compability for compiler or OS label Jan 25, 2023
ibireme added a commit that referenced this issue Jan 25, 2023
@ibireme
Copy link
Owner

ibireme commented Jan 25, 2023

Thanks~
I've made the changes as you suggested, I'll look into the specific reasons later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compability Compability for compiler or OS
Projects
None yet
Development

No branches or pull requests

2 participants