| Issue |
166721
|
| Summary |
Clang 20.1.0 (assertions)
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
Dong-hui-li
|
code:
#include <string>
#include <memory>
namespace DataSecurity {
template<typename CryptoPolicy = int>
class SecureContainer : public std::string {
public:
using std::string::string;
size_t calculateIntegrity() const {
return this->size() * 0x9E3779B9;
}
bool validateContent() const {
return !this->empty();
}
};
class DataHandler {
public:
template<typename InputType>
static auto processInput(InputType&& source) {
return SecureContainer(std::forward<InputType>(source));
}
};
class ConfigurationManager {
private:
SecureContainer<> config_data;
public:
ConfigurationManager(const std::string& settings)
: config_data(DataHandler::processInput(settings)) {}
size_t getSettingsHash() const {
return config_data.calculateIntegrity();
}
};
}
class Application {
DataSecurity::ConfigurationManager config;
public:
Application() : config("default_settings") {}
void initialize() {
auto settings_value = config.getSettingsHash();
if (settings_value > 0) {
std::string data_sample = "runtime_data";
auto processed = DataSecurity::DataHandler::processInput(data_sample);
}
}
};
int main() {
Application app;
app.initialize();
std::string user_data = "user_provided_content";
auto secured_data = DataSecurity::DataHandler::processInput(user_data);
return 0;
}
-std=c++23
Clang 19: Works correctly (as you confirmed)
Clang 18 & 20.1.0: Contains the template deduction guide bug
This suggests the bug was introduced in version 18 and potentially fixed in a later version than 20.1.0
clang++: /root/llvm-project/clang/lib/Sema/SemaTemplateDeductionGuide.cpp:396: clang::NamedDecl* {anonymous}::ConvertConstructorToDeductionGuideTransform::transformConstructor(clang::FunctionTemplateDecl*, clang::CXXConstructorDecl*): Assertion `getDepthAndIndex(NewParam).first == 0 && "Unexpected template parameter depth"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-20.1.0/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-14.2.0 -fcolor-diagnostics -fno-crash-diagnostics -std=c++23 <source>
1. <source>:33:61: current parser token ')'
2. <source>:4:1: parsing namespace 'DataSecurity'
3. <source>:27:5: parsing struct/union/class body 'DataSecurity::ConfigurationManager'
4. <source>:22:21: instantiating function definition 'DataSecurity::DataHandler::processInput<const std::basic_string<char> &>'
#0 0x0000000003e64af8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-20.1.0/bin/clang+++0x3e64af8)
#1 0x0000000003e627b4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-20.1.0/bin/clang+++0x3e627b4)
#2 0x0000000003daec88 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x0000786821242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007868212969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x0000786821242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007868212287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x000078682122871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x0000786821239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x0000000007363643 (anonymous namespace)::ConvertConstructorToDeductionGuideTransform::transformConstructor(clang::FunctionTemplateDecl*, clang::CXXConstructorDecl*) SemaTemplateDeductionGuide.cpp:0:0
#10 0x0000000007364794 clang::Sema::DeclareImplicitDeductionGuides(clang::TemplateDecl*, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-20.1.0/bin/clang+++0x7364794)
#11 0x0000000006f67457 LookupDirect(clang::Sema&, clang::LookupResult&, clang::DeclContext const*) SemaLookup.cpp:0:0
#12 0x0000000006f52b12 clang::Sema::LookupQualifiedName(clang::LookupResult&, clang::DeclContext*, bool) (/opt/compiler-explorer/clang-assertions-20.1.0/bin/clang+++0x6f52b12)
#13 0x0000000006f3170e clang::Sema::DeduceTemplateSpecializationFromInitializer(clang::TypeSourceInfo*, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>) (/opt/compiler-explorer/clang-assertions-20.1.0/bin/clang+++0x6f3170e)
#14 0x0000000006e24365 clang::Sema::BuildCXXTypeConstructExpr(clang::TypeSourceInfo*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-assertions-20.1.0/bin/clang+++0x6e24365)
#15 0x00000000073c8b5d clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCXXUnresolvedConstructExpr(clang::CXXUnresolvedConstructExpr*) SemaTemplateInstantiate.cpp:0:0
#16 0x00000000073a846c clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#17 0x00000000073ab6f5 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformInitializer(clang::Expr*, bool) (.part.0) SemaTemplateInstantiate.cpp:0:0
#18 0x00000000073aba9c clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformReturnStmt(clang::ReturnStmt*) SemaTemplateInstantiate.cpp:0:0
#19 0x00000000073d6cbe clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*, bool) SemaTemplateInstantiate.cpp:0:0
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs