https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82090
Bug ID: 82090 Summary: Bogus warning: ‘magic_p’ may be used uninitialized in this function [-Wmaybe-uninitialized] Product: gcc Version: 7.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: hjl.tools at gmail dot com Target Milestone: --- [hjl@gnu-efi-2 tmp]$ cat foo.c typedef int __libc_lock_t; void malloc_printerr(const char *str) __attribute__ ((noreturn)); extern __libc_lock_t foo; static void * mem2chunk_check (void *mem, unsigned char **magic_p) { if (!mem) return (( void *)0) ; if (magic_p) *magic_p = (unsigned char *) mem; return mem; } void * realloc_check (void *oldmem, unsigned int bytes, const void *caller) { unsigned char *magic_p; void * oldp = mem2chunk_check (oldmem, &magic_p); (void) ({ int ignore; if (__builtin_constant_p (0) && (0) == 0) __asm __volatile ("cmpl $0, __libc_multiple_threads(%%rip)\n\t" "je 0f\n\t" "lock; decl %0\n\t" "jne 1f\n\t" "jmp 24f\n\t" "0:\tdecl %0\n\t" "je 24f\n\t" "1:\tlea %0, %%" "rdi" "\n" "2:\tsub $128, %%" "rsp" "\n" ".cfi_adjust_cfa_offset 128\n" "3:\tcallq __lll_unlock_wake_private\n" "4:\tadd $128, %%" "rsp" "\n" ".cfi_adjust_cfa_offset -128\n" "24:" : "=m" (foo), "=&D" (ignore) : "m" (foo) : "ax", "cx", "r11", "cc", "memory"); else __asm __volatile ("cmpl $0, __libc_multiple_threads(%%rip)\n\t" "je 0f\n\t" "lock; decl %0\n\t" "jne 1f\n\t" "jmp 24f\n\t" "0:\tdecl %0\n\t" "je 24f\n\t" "1:\tlea %0, %%" "rdi" "\n" "2:\tsub $128, %%" "rsp" "\n" ".cfi_adjust_cfa_offset 128\n" "3:\tcallq __lll_unlock_wake\n" "4:\tadd $128, %%" "rsp" "\n" ".cfi_adjust_cfa_offset -128\n" "24:" : "=m" (foo), "=&D" (ignore) : "m" (foo), "S" (0) : "ax", "cx", "r11", "cc", "memory"); }); if (!oldp) malloc_printerr ("realloc(): invalid pointer"); *magic_p ^= 0xFF; return oldp; } [hjl@gnu-efi-2 tmp]$ gcc -Wall foo.c -S -O3 foo.c: In function ‘realloc_check’: foo.c:25:12: warning: ‘magic_p’ may be used uninitialized in this function [-Wmaybe-uninitialized] *magic_p ^= 0xFF; ~~~~~~~~~^~~~~~~ [hjl@gnu-efi-2 tmp]$