This is an archive of the discontinued LLVM Phabricator instance.

Fixing surplus assert condition in EvaluateTemporary
Needs ReviewPublic

Authored by zhouyizhou on Feb 10 2022, 3:25 PM.

Details

Summary

In LLVM/Clang Debug build, following code will trigger the assert to fire:

typedef bool Var;
bool foobool() {
return (bool().Var::~Var(), false);
}

I think the non record type temporary object should also be allowed here.
Thanks in advance

Zhouyi Zhou
zhouzhouyi@gmail.com

Diff Detail

Event Timeline

zhouyizhou requested review of this revision.Feb 10 2022, 3:25 PM
zhouyizhou created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 10 2022, 3:25 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
zhouyizhou edited the summary of this revision. (Show Details)
Herald added a project: Restricted Project. · View Herald TranscriptMar 18 2022, 5:27 PM

I'm not sure this is the right fix. If we were handling the pseudo-destructor correctly, I would expect the following to compile successfully:

typedef bool Var;
constexpr bool foobool() {
	return (bool().Var::~Var(), false); 
}

Thank Eli for your comment and guidance and sorry to have carelessly neglected your comment for 7 months!

I'm not sure this is the right fix. If we were handling the pseudo-destructor correctly, I would expect the following to compile successfully:

typedef bool Var;
constexpr bool foobool() {
	return (bool().Var::~Var(), false); 
}

Yes, g++ can compile above code successfully, while we can't.
I am going to try to fix above (I am a beginner who eager to learn ;-)

Cheers
Zhouyi

zhouyizhou edited the summary of this revision. (Show Details)Nov 4 2022, 4:35 PM