https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65244
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed|2015-02-27 00:00:00 |2021-3-31 Known to fail| |10.2.0, 11.0, 4.9.4, 5.5.0, | |6.4.0, 7.2.0, 8.3.0, 9.1.0 Known to work|4.8.2, 5.0 | CC| |msebor at gcc dot gnu.org --- Comment #15 from Martin Sebor <msebor at gcc dot gnu.org> --- The warning with -Og disappeared with r212559 but still comes back on trunk with -Og -ftree-bit-ccp. With that, as the comment in gimple-low.c says, a call to posix_memalign() is lowered into: void *tem; res = posix_memalign (&tem, align, size); if (res == 0) ptr = __builtin_assume_aligned (tem, align); and at -Og it looks like the two conditionals don't get cleaned up as nicely as at -O1 and lead to an IL that the warning is designed to trigger on. This could be handled by the warning but unless this can come up with other (especially non-builtin) functions it may not be worth the trouble. $ cat pr65244.c && gcc -Og -S -Wall -ftree-bit-ccp -fdump-tree-uninit=/dev/stdout pr65244.c void exit(int __status) __attribute__ ((__noreturn__)); int posix_memalign(void **__memptr, __SIZE_TYPE__ __alignment, __SIZE_TYPE__ __size); void *f(void) { void *ptr; if (posix_memalign(&ptr, 16, 256) != 0) exit(1); return ptr; } ;; Function f (f, funcdef_no=0, decl_uid=1949, cgraph_uid=1, symbol_order=0) pr65244.c: In function ‘f’: pr65244.c:10:12: warning: ‘ptr’ may be used uninitialized in this function [-Wmaybe-uninitialized] 10 | return ptr; | ^~~ pr65244.c:5:11: note: ‘ptr’ was declared here 5 | void *ptr; | ^~~ void * f () { void * D.1957; void * ptr; int _1; void * _6; <bb 2> [local count: 1073741824]: _1 = posix_memalign (&D.1957, 16, 256); if (_1 == 0) goto <bb 3>; [50.00%] else goto <bb 7>; [50.00%] <bb 7> [local count: 536870912]: goto <bb 4>; [100.00%] <bb 3> [local count: 536870913]: _6 = D.1957; <bb 4> [local count: 1073741824]: # ptr_2 = PHI <ptr_5(D)(7), _6(3)> if (_1 != 0) goto <bb 5>; [0.04%] else goto <bb 6>; [99.96%] <bb 5> [local count: 429496]: exit (1); <bb 6> [local count: 1073312329]: return ptr_2; }