https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79082
Martin Sebor changed:
What|Removed |Added
Status|WAITING |RESOLVED
Resolution|---
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79082
--- Comment #14 from Franz Sirl ---
I just finished testing with r245021 and now the warnings are as expected. All
warnings are there with -Wformat-truncation=2 and also -Wformat-truncation=1
behaves according to the documentation (BTW, there's
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79082
Martin Sebor changed:
What|Removed |Added
Status|NEW |WAITING
--- Comment #13 from Martin
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79082
--- Comment #12 from Martin Sebor ---
(In reply to Sylvestre Ledru from comment #11)
> Other testcase:
> ---
> #include
> #include
> int main() {
> char* buf = new char[10];
> uint8_t data = 255;
> printf("%.2x\n", data);//
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79082
Sylvestre Ledru changed:
What|Removed |Added
CC||sylvestre at debian dot org
---
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79082
--- Comment #10 from Martin Sebor ---
Only three out of the five patches for bug 78703 have been committed. I'm
still waiting for approval of the substantive patch 4, and patch 5 depends on
it. With those committed I think the warning should
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79082
--- Comment #9 from Franz Sirl ---
With r244892 and -O2 -Wformat-truncation=2 I nearly get the warnings I expect.
What remains is case 3, but this seems to be a small deficiency in VRP. For the
term I used ((val < 0) ? -(val % 100) : (val %
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79082
--- Comment #8 from Martin Sebor ---
> case 3. You can see that in the dump created by the -ftree-dump-vrp option
> where the argument is assumed to include the negative subrange:
>
> Value ranges after VRP:
> ...
> iftmp.0_11: [-99, 99]
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79082
--- Comment #7 from Martin Sebor ---
Except for #8, none of the sprintf calls in the extended testcase in attachment
40566 can be handled as accurately at -O0 as with optimization because the
arguments to the format directives are treated as if
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79082
--- Comment #6 from Franz Sirl ---
Created attachment 40566
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40566=edit
extended testcase
Hmm, looks like there is an off-by-one bug lurking here?
To clarify my setup, here are the warnings
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79082
--- Comment #5 from Martin Sebor ---
I see no warning at -O0 on
snprintf (buffer, 4, "%03hx", val & 0xfff);
or at -O2 on:
snprintf (buffer, 3, "%2d", (val < 0) ? -(val % 100) : val % 100);
(It does warn at -O0 as expected.) This is on
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79082
--- Comment #4 from Franz Sirl ---
Hmm, %hhd is not usable on some of our platforms and also only really helpful
with exact %x outputs:
snprintf(buffer, 3, "%02hhx", val);
What about:
snprintf(buffer, 4, "%03hx", val & 0xfff);
Here the
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79082
Martin Sebor changed:
What|Removed |Added
See Also||https://gcc.gnu.org/bugzill
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79082
Martin Sebor changed:
What|Removed |Added
Severity|normal |enhancement
--- Comment #2 from Martin
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79082
Richard Biener changed:
What|Removed |Added
Keywords||diagnostic
15 matches
Mail list logo