[llvm-bugs] [Bug 40183] New: clang++ errors when trying to call a constructor that automatically deduces its class template parameters from a Callable -templated class
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Dec 29 12:40:40 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=40183
Bug ID: 40183
Summary: clang++ errors when trying to call a constructor that
automatically deduces its class template parameters
from a Callable -templated class
Product: clang
Version: 7.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++'17
Assignee: unassignedclangbugs at nondot.org
Reporter: jacksonmcneillnospam at gmail.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
Created attachment 21279
--> https://bugs.llvm.org/attachment.cgi?id=21279&action=edit
output of clang, including source, compile commands, and terminal output on
crash
clang version 7.0.0-3 (tags/RELEASE_700/final)
Target: x86_64-pc-linux-gnu
This is best described with code.
/*!
* Compile with: [g++ or clang++] -std=c++17 bug_code.cpp
*/
//Minimal replacement for std::function to demonstrate bug
template<typename> class callable_templated_class;
template<typename return_t, typename args_t>
class callable_templated_class<return_t(args_t)>
{
public:
callable_templated_class()
{
}
};
// You can remove one of these and specify int inside the
callable_templated_class<...> callback and still get the error. Removing both
and specifying int on both will not exhibit the error.
template <typename return_t, typename args_t>
class bug_class
{
public:
bug_class(int please_see_comment,
callable_templated_class<return_t(args_t)> callback)
/*!
* The 'int' at the beginning of the function is necessary to trigger the
bug in GCC (but not clang). In my testing, it can by any type -- but it must be
present.
*/
{
}
};
template <typename return_t, typename args_t>
class no_gcc_bug
{
public:
no_gcc_bug(callable_templated_class<return_t(args_t)> callback)
{
}
};
int main()
{
auto instantiation = callable_templated_class<int(int)>();
auto this_is_fine_in_gcc = new no_gcc_bug(instantiation); //works in
gcc, does not work in clang(crash)
auto this_will_error = new bug_class(0,instantiation); //This is a bug
in both GCC and clang.
//In GCC: It errors - I don't think it should(check standard?). At the
very least, the error message is wrong/confusing.
//In Clang: It crashes.
return 0;
}
Clang will crash trying to call the constructor for `no_gcc_bug`. I believe
clang is crashing while trying to deduce `return_t` or `args_t` from
`callable_templated_class<return_t(args_t)`. I think this because clang will
not crash if you remove the template from `no_gcc_bug` and use
`callable_templated_class<int(int)>` instead. However, if you keep the template
for `return_t` and/or `args_t`, clang will crash.
A similar bug exists in GCC, so I will link to the gcc bugzilla post when it's
up. I'm not sure of the correct behavior here, but it shouldn't crash.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181229/0c562ac3/attachment.html>
More information about the llvm-bugs
mailing list