Skip to content

[clang][bytecode] Allow memory leaks before C++20 #137445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion clang/lib/AST/ByteCode/InterpState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ bool InterpState::maybeDiagnoseDanglingAllocations() {
<< (It.second.size() - 1) << Source->getSourceRange();
}
}
return NoAllocationsLeft;
// Keep evaluating before C++20, since the CXXNewExpr wasn't valid there
// in the first place.
return NoAllocationsLeft || !getLangOpts().CPlusPlus20;
}

StdAllocatorCaller InterpState::getStdAllocatorCaller(StringRef Name) const {
Expand Down
7 changes: 7 additions & 0 deletions clang/test/AST/ByteCode/cxx11-pedantic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@ namespace DynamicCast {
// both-note {{dynamic_cast}}
};
}

namespace NewDelete {
struct T {
int n : *new int(4); // both-warning {{constant expression}} \
// both-note {{until C++20}}
};
}
Loading