This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Forbid __builtin_return_address when inlining

__builtin_return_address(0) returns the wrong address if its caller
has been inlined.  Weirdly, we never seem to have detected this
before, but it surely must be wrong.

OK for trunk?


2006-11-22  Andrew Haley  <>

	* tree-inline.c (inline_forbidden_p_1): Forbid

Index: tree-inline.c
--- tree-inline.c	(revision 118936)
+++ tree-inline.c	(working copy)
@@ -1388,6 +1388,16 @@ inline_forbidden_p_1 (tree *nodep, int *
 		   "it uses __builtin_return or __builtin_apply_args");
 	    return node;
+	    /* We can't inline functions that call
+	       __builtin_return_address because it would return the
+	       address of the caller of the function the inline has
+	       been inlined into.  */
+	    inline_forbidden_reason
+	      = G_("function %q+F can never be inlined because "
+		   "it uses __builtin_return_address");
+	    return node;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]