[PATCH] D50805: Don't warn on returning the address of a label

Reid Kleckner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 15 13:59:08 PDT 2018


rnk added inline comments.


================
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:7872-7874
-def warn_ret_addr_label : Warning<
-  "returning address of label, which is local">,
-  InGroup<ReturnStackAddress>;
----------------
lebedev.ri wrote:
> Why completely drop the diagnostic just because it is undesired in linux code?
> Why not just add an `-Wreturn-stack-address` diag option instead, and disable it if undesired?
There's just no use for it. There is no actual lifetime issue here. Just because a label goes out of scope doesn't invalidate it for use with some future execution of the scope. Labels aren't variables, we should never have had this check in the first place, IMO.


https://reviews.llvm.org/D50805





More information about the cfe-commits mailing list