https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109164
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|tree-optimization |c++
CC| |jason at gcc dot gnu.org
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
So we have
;; Function Struct& _ZTW16thread_local_ref() (null)
;; enabled by -tree-original
if (_ZTH16thread_local_ref != 0B)
{
<<cleanup_point <<< Unknown tree: expr_stmt
_ZTH16thread_local_ref () >>>>>;
}
return <retval> = thread_local_ref;
which is eventually inlined. But 'thread_local_ref' is TREE_READONLY and
thus may_be_aliased is false and the readonly-global exception triggers:
/* If the reference is based on a decl that is not aliased the call
cannot possibly clobber it. */
if (DECL_P (base)
&& !may_be_aliased (base)
/* But local non-readonly statics can be modified through recursion
or the call may implement a threading barrier which we must
treat as may-def. */
&& (TREE_READONLY (base)
|| !is_global_var (base)))
return false;
I think it's a mistake for the frontend to set TREE_READONLY on the
decl if it requires initialization (we've been there for other runtime
initialized globals).
Thus -> C++ FE bug.