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

Closed
wants to merge 1 commit into from
Closed

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];
      |          ^~~

Comment on lines 159 to +130
if (sign < 0) *tmp++ = '-';
if (tmp > buf + FBUFFER_APPEND_LONG_BUFFER_SIZE) UNREACHABLE;
Copy link
Member

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++ = '-';

```
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];
      |          ^~~
```
@byroot
Copy link
Member

byroot commented Oct 18, 2024

@hsbt I see you rebased that PR, are you taking care of this one? I'm not able to reproduce the warning and I don't see it on CI either.

@byroot
Copy link
Member

byroot commented Oct 30, 2024

This code changed quite a bit, if you still see the warning please let me know.

@byroot byroot closed this Oct 30, 2024
@hsbt
Copy link
Member

hsbt commented Oct 31, 2024

I only rebase with master each PRs because I can do that under the ruby org.

GCC 11 is not latest version today. It's not problem for us.

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.

4 participants