Array-bounds Warning For `memcpy((void*)0x1234, P, N)`, Where N Is ...

Có thể bạn quan tâm

GCC Bugzilla – Bug 103768 array-bounds warning for `memcpy((void*)0x1234, p, n)`, where n is greater than 8 Last modified: 2021-12-19 11:36:33 UTC
  • Home
  • | New
  • | Browse
  • | Search
  • | [?]
  • | Reports
  • | Help
  • | New Account
  • | Log In Remember [x]
  • | Forgot Password Login: [x]
Bug 103768 - array-bounds warning for `memcpy((void*)0x1234, p, n)`, where n is greater than 8 Summary: array-bounds warning for `memcpy((void*)0x1234, p, n)`, where n is greater th...
Status: RESOLVED DUPLICATE of bug 99578
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 11.2.0
Importance: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
Reported: 2021-12-19 11:33 UTC by Paul Menzel
Modified: 2021-12-19 11:36 UTC (History)
CC List: 0 users
See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:
Attachments
Add an attachment (proposed patch, testcase, etc.)
Note You need to log in before you can comment on or make changes to this bug.
Description Paul Menzel 2021-12-19 11:33:35 UTC In the SeaBIOS list thread *[PATCH] memmap: Fix gcc out-of-bounds warning* [1], the array out of bounds warning below from at least GCC 11.2.0 is discussed: ``` In file included from src/fw/smm.c:18: src/fw/smm.c: In function 'smm_save_and_copy': src/string.h:23:16: warning: '__builtin_memcpy' offset [0, 511] is out of the bounds [0, 0] [-Warray-bounds] 23 | #define memcpy __builtin_memcpy src/fw/smm.c:148:5: note: in expansion of macro 'memcpy' 148 | memcpy(&smm->cpu, &initsmm->cpu, sizeof(smm->cpu)); | ^~~~~~ src/fw/smm.c: In function 'smm_relocate_and_restore': src/string.h:23:16: warning: '__builtin_memcpy' offset [0, 511] is out of the bounds [0, 0] [-Warray-bounds] 23 | #define memcpy __builtin_memcpy src/fw/smm.c:171:5: note: in expansion of macro 'memcpy' 171 | memcpy(&initsmm->cpu, &smm->cpu, sizeof(initsmm->cpu)); | ^~~~~~ src/fw/smm.c: In function 'handle_smi': src/string.h:23:16: warning: '__builtin_memcpy' offset [0, 511] is out of the bounds [0, 0] [-Warray-bounds] 23 | #define memcpy __builtin_memcpy src/fw/smm.c:88:13: note: in expansion of macro 'memcpy' 88 | memcpy(&newsmm->backup1, &smm->cpu, sizeof(newsmm->backup1)); | ^~~~~~ src/string.h:23:16: warning: '__builtin_memcpy' offset [0, 511] is out of the bounds [0, 0] [-Warray-bounds] 23 | #define memcpy __builtin_memcpy src/fw/smm.c:89:13: note: in expansion of macro 'memcpy' 89 | memcpy(&newsmm->backup2, &smm->cpu, sizeof(newsmm->backup2)); | ^~~~~~ ``` Kevin writes: > Yes - I see that as well in smm.c. Alas, I don't have a fix for it. > It seems to me that gcc is producing bogus warnings here. It looks > like anything of the form "memcpy((void*)0x1234, p, n)" where n is > greater than 8 produces this warning. It's a requirement to memcpy to > a physical memory address. Disabling the warning would require adding > both "-Wno-array-bounds -Wno-stringop-overflow" to the build. > > Maybe someone else has an idea on how to suppress this warning. The SeaBIOS source code is available in a git repository [2]. `make olddefconfig && make -j$(nproc)` reproduces the warning. [1]: https://mail.coreboot.org/hyperkitty/list/seabios@seabios.org/thread/KCV5A4GZQDFNANU7QZYR4Y6ZNFGMEJQN/ [2]: https://review.coreboot.org/plugins/gitiles/seabios/+/refs/tags/rel-1.15.0/src/fw/smm.c#148 Comment 1 Andrew Pinski 2021-12-19 11:36:33 UTC Dup of bug 99578. *** This bug has been marked as a duplicate of bug 99578 ***
  • Format For Printing
  • - XML
  • - Clone This Bug
  • - Top of page

Từ khóa » C 0x1234