[Bug middle-end/84095] [8 Regression] false-positive -Wrestrict warnings for memcpy within array

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jan 29 20:22:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84095

--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
Thanks.

Just for reference in case more of these should pop up, I see two -Wrestrict
instances in my build (below).  The first one looks correct but the second one
could be an instance of the false positive reported here.  If you come across
others please open new bugs (it would be helpful if I could reproduce your
build so if you can share your config file and/or whatever else I might need
that would be great).

net/mac80211/cfg.c:2794:3: warning: ‘memcpy’ source argument is the same as
destination [-Wrestrict]
   memcpy(pos, beacon->probe_resp, beacon->probe_resp_len);

drivers/iommu/amd_iommu.c: In function ‘get_alias’:
drivers/iommu/amd_iommu.c:310:4: warning: ‘memcpy’ accessing 32 bytes at
offsets 0 and 0 overlaps 32 bytes at offset 0 [-Wrestrict]
    memcpy(amd_iommu_dev_table[pci_alias].data,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           amd_iommu_dev_table[devid].data,
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           sizeof(amd_iommu_dev_table[pci_alias].data));
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

PS The breakdown of all warnings I see is below (the Unique column gives the
number of distinct origins of the warning, and the Files column the number of
distinct originating files):

Diagnostic                        Count   Unique    Files
-Wattributes                       2139        1        1
-Wattribute-alias                   465        3        3
-Wpacked-not-aligned                 45       17        3
-Wstringop-truncation                39       23       10
-Wformat-truncation=                 21       21       15
-Wint-in-bool-context                10       10        2
-Wformat-overflow=                    3        3        2
-Wstringop-overflow=                  2        2        2
-Wrestrict                            2        2        2
-Warray-bounds                        2        2        2
-Wsizeof-pointer-memaccess            1        1        1
-Wnonnull                             1        1        1


More information about the Gcc-bugs mailing list