This is the mail archive of the gcc-patches@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]

Re: [C++ Patch] PR 65579 ("gcc requires definition of a static constexpr member...")


Hi again,

On 24/10/2017 20:58, Jason Merrill wrote:
This seems like an odd place to add the complete_type call.  What
happens if we change the COMPLETE_TYPE_P (type) in
cp_apply_type_quals_to_decl to COMPLETE_TYPE_P (complete_type (type))?
Finally I'm back with some information.

Simply doing the above doesn't fully work. The first symptom is the failure of g++.dg/init/mutable1.C which is precisely the testcase that you added together with the "|| !COMPLETE_TYPE_P (type)" itself: clearly, the additional condition isn't able anymore to do its work, because, first, when the type isn't complete, TYPE_HAS_MUTABLE_P (type) is false and then, when in fact it would be found true, we check !COMPLETE_TYPE_P (complete_type (type)) which is false, because completing succeeded.

Thus it seems we need at least something like:

   TREE_TYPE (decl) = type = complete_type (type);

   if (TYPE_HAS_MUTABLE_P (type) || !COMPLETE_TYPE_P (type))
     type_quals &= ~TYPE_QUAL_CONST;

But then, toward the end of the testsuite, we notice a more serious issue, which is unrelated to the above: g++.old-deja/g++.pt/poi1.C

// { dg-do assemble  }
// Origin: Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>

template <class T>
class TLITERAL : public T
    {
    int x;
    };

class GATOM;

typedef TLITERAL<GATOM> x;
extern TLITERAL<GATOM> y;

also fails:

poi1.C: In instantiation of ‘class TLITERAL<GATOM>’:
poi1.C:13:24:   required from here
poi1.C:5:7: error: invalid use of incomplete type ‘class GATOM’
 class TLITERAL : public T
poi1.C:10:7: note: forward declaration of ‘class GATOM’
 class GATOM;

that is, trying to complete GATOM at the 'extern TLITERAL<GATOM> y;" line obviously fails. Note, in case isn't obvious, that this happens exactly for the cp_apply_type_quals_to_decl call at the end of grokdeclarator which I tried to change in my first try: the failure of poi1.C seems rather useful to figure out what we want to do for this bug.

Well, as expected, explicitly checking VAR_P && DECL_DECLARED_CONSTEXPR_P works again - it seems to me that after all it could make sense given the comment precisely talking about the additional complexities related to constexpr. Anyway, I'm attaching the corresponding complete patch.

Thanks!
Paolo.

/////////////////////

Attachment: patch_65579_2
Description: Text document


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