This is the mail archive of the gcc-bugs@gcc.gnu.org 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]

[Bug c++/70353] [5/6 regression] ICE on __PRETTY_FUNCTION__ in a constexpr function


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70353

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu.org,
                   |                            |jakub at gcc dot gnu.org

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The reason for the ICE is that __PRETTY_FUNCTION__/__FUNCTION__/__func__ are
TREE_STATIC (artificial) VAR_DECLs in the context of the corresponding
constexpr function, because of the TREE_STATIC we don't want to remap it, and
constexpr.c calls copy_fn with NULL cfun (most other callers of inlining APIs
have cfun non-NULL and usually cfun->decl matching id->dst_fn).
For the ICE, I guess we can do something like:
--- gcc/tree-inline.c.jj        2016-03-16 18:50:47.000000000 +0100
+++ gcc/tree-inline.c   2016-03-23 16:27:08.723926525 +0100
@@ -614,9 +614,11 @@ remap_decls (tree decls, vec<tree, va_gc
       if (can_be_nonlocal (old_var, id))
        {
          /* We need to add this variable to the local decls as otherwise
-            nothing else will do so.  */
+            nothing else will do so.  Don't do this if there is no current
+            function, e.g. during constexpr handling calling copy_fn.  */
          if (TREE_CODE (old_var) == VAR_DECL
-             && ! DECL_EXTERNAL (old_var))
+             && ! DECL_EXTERNAL (old_var)
+             && cfun)
            add_local_decl (cfun, old_var);
          if ((!optimize || debug_info_level > DINFO_LEVEL_TERSE)
              && !DECL_IGNORED_P (old_var)
But, that is insufficient, as e.g. for the #c8 testcase we then get unresolved
external symbol, because the definition of the static var is never emitted.

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