Summary: | gcc assumes errno might be negative and issues unnecessary warning | ||
---|---|---|---|
Product: | gcc | Reporter: | Zbigniew Jędrzejewski-Szmek <zbyszek> |
Component: | middle-end | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | UNCONFIRMED --- | ||
Severity: | normal | CC: | sjames |
Priority: | P3 | Keywords: | diagnostic |
Version: | 4.9.0 | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | ||
Bug Depends on: | |||
Bug Blocks: | 114952 | ||
Attachments: |
sample program
compilation logs processed source sample program |
Description
Zbigniew Jędrzejewski-Szmek
2014-07-18 20:46:15 UTC
Created attachment 33150 [details]
compilation logs
Created attachment 33151 [details]
processed source
Created attachment 33152 [details]
sample program
C99 also has this requirement. But C89 did not.
>Values for errno are now required to be distinct positive values rather than
> non-zero values. This change is for alignment with the ISO/IEC 9899:1999
> standard.
So using -std=gnu99 should allow this to not be unitilaized except GCC has no way to know you are reading from errno just yet.
(In reply to Andrew Pinski from comment #4) > C99 also has this requirement. But C89 did not. The warnings are "best effort" anyway. So even if the standards did *not* say that, gcc could skip the warning since existing systems all work this way anyway. I think it could make for a nice optimization, when compiling for C99, but that is not what I'm asking for atm. > >Values for errno are now required to be distinct positive values rather than > > non-zero values. This change is for alignment with the ISO/IEC 9899:1999 > > standard. > > So using -std=gnu99 should allow this to not be unitilaized except GCC has > no way to know you are reading from errno just yet. Wouldn't it be a matter of annotating read() call with the sideffect of "return value >= 0 || errno > 0" ? |