Array-bounds Warning For `memcpy((void*)0x1234, P, N)`, Where N Is ...
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]
|
|
|
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
- Home
- | New
- | Browse
- | Search
- | [?]
- | Reports
- | Help
- | New Account
- | Log In Remember [x]
- | Forgot Password Login: [x]
Từ khóa » C 0x1234
-
Convert 0x1234 To 0x11223344 - C++ - Stack Overflow
-
C Programming Examples | C Source Code | C Problems & Solutions
-
C Programming - Bitwise Operations - C++ Forum
-
Easy Hex String "0x1234" To Integer Conversion? - C# / C Sharp
-
C++ 将 0x1234 转换为 0x11223344 - 无涯教程网
-
Understanding The Pointers In C/C++ - Leon Dong
-
Expression Examples - µVision User's Guide - Keil
-
[PDF] CS 11 C Track: Lecture 5
-
Rmsharedstpool Command - IBM
-
Lsaddphysvolcandidate Command - IBM
-
Source - Hackage
-
Binary, Decimal, HEX, And Octal Constants - µVision User's Guide
-
Hexadecimal 0x1234 = 4660