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

Silence GCC 11 warnings #468

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

xtkoba
Copy link

@xtkoba xtkoba commented May 8, 2021

compiling ../../../../ext/json/generator/generator.c
In file included from ../../../../ext/json/generator/generator.c:1:
In function 'freverse',
    inlined from 'fltoa' at ../../../../ext/json/generator/../fbuffer/fbuffer.h:158:5,
    inlined from 'fbuffer_append_long' at ../../../../ext/json/generator/../fbuffer/fbuffer.h:165:25,
    inlined from 'generate_json_fixnum' at ../../../../ext/json/generator/generator.c:974:5,
    inlined from 'generate_json_integer' at ../../../../ext/json/generator/generator.c:987:9,
    inlined from 'mInteger_to_json' at ../../../../ext/json/generator/generator.c:439:5:
../../../../ext/json/generator/../fbuffer/fbuffer.h:145:45: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  145 |         c = *end, *end-- = *start, *start++ = c;
      |                                    ~~~~~~~~~^~~
../../../../ext/json/generator/generator.c: In function 'mInteger_to_json':
../../../../ext/json/generator/../fbuffer/fbuffer.h:164:10: note: at offset 20 into destination object 'buf' of size 20
  164 |     char buf[20];
      |          ^~~

```
compiling ../../../../ext/json/generator/generator.c
In file included from ../../../../ext/json/generator/generator.c:1:
In function 'freverse',
    inlined from 'fltoa' at ../../../../ext/json/generator/../fbuffer/fbuffer.h:158:5,
    inlined from 'fbuffer_append_long' at ../../../../ext/json/generator/../fbuffer/fbuffer.h:165:25,
    inlined from 'generate_json_fixnum' at ../../../../ext/json/generator/generator.c:974:5,
    inlined from 'generate_json_integer' at ../../../../ext/json/generator/generator.c:987:9,
    inlined from 'mInteger_to_json' at ../../../../ext/json/generator/generator.c:439:5:
../../../../ext/json/generator/../fbuffer/fbuffer.h:145:45: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  145 |         c = *end, *end-- = *start, *start++ = c;
      |                                    ~~~~~~~~~^~~
../../../../ext/json/generator/generator.c: In function 'mInteger_to_json':
../../../../ext/json/generator/../fbuffer/fbuffer.h:164:10: note: at offset 20 into destination object 'buf' of size 20
  164 |     char buf[20];
      |          ^~~
```
Comment on lines 159 to +160
if (sign < 0) *tmp++ = '-';
if (tmp > buf + FBUFFER_APPEND_LONG_BUFFER_SIZE) UNREACHABLE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition means that tmp overflowed.
Doesn't it result in another warning?

Suggested change
if (sign < 0) *tmp++ = '-';
if (tmp > buf + FBUFFER_APPEND_LONG_BUFFER_SIZE) UNREACHABLE;
if (tmp >= buf + FBUFFER_APPEND_LONG_BUFFER_SIZE) UNREACHABLE;
if (sign < 0) *tmp++ = '-';

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

Successfully merging this pull request may close these issues.

None yet

2 participants