[frama-clang] std::forward with non-primitive type causes NON TERMINATING
Steps to reproduce the issue
Please find attached two example sources that demonstrate the issue: fails.cpp works.cpp
Please find attached the narrowed example sources that demonstrate the issue with std::forward
alone:
fails.cppworks.cpp
Further investigation details can be found in the comments. What follows here is the original issue description:
> cat fails.cpp
#include <memory>
struct Foo {
int val;
Foo(int val) : val(val) {}
int bar() { return val; }
};
int main(int argc, char **argv) {
std::unique_ptr<Foo> foo1(new Foo(argc));
std::unique_ptr<Foo> foo2 = std::move(foo1);
return foo2->bar();
}
> frama-c -deps fails.cpp
Expected behaviour
[kernel] Parsing fails.cpp (external front-end)
Now output intermediate result
...
[from] Function main:
__malloc_main_l10 FROM argc
\result FROM argc
[from] ====== END OF DEPENDENCIES ======
Actual behaviour
[kernel] Parsing fails.cpp (external front-end)
Now output intermediate result
...
[from] Function main:
NON TERMINATING - NO EFFECTS
[from] ====== END OF DEPENDENCIES ======
Minimal working diff
It works if we avoid the move assignment:
> diff -u fails.cpp works.cpp
--- fails.cpp 2021-06-21 10:40:26.613967584 +0000
+++ works.cpp 2021-06-21 10:38:12.276859713 +0000
@@ -8,6 +8,5 @@
int main(int argc, char **argv) {
std::unique_ptr<Foo> foo1(new Foo(argc));
- std::unique_ptr<Foo> foo2 = std::move(foo1);
- return foo2->bar();
+ return foo1->bar();
}
Contextual information
- Frama-C: framac/frama-c:22.0 Docker Image ID e45780e160f1
- Plug-in used: frama-clang-0.0.10 built from official source drop
- Compiler: Debian clang version 11.1.0
- Target: x86_64-pc-linux-gnu
Additional information
One more observation is that the plugin is unable to parse a preprocessed source file:
> clang++-11 -E -o works.ii works.cpp
> frama-c -deps works.ii
[kernel] Parsing works.ii (external front-end)
works.ii:316:32: error: __int128 is not supported on this target
template<> struct __is_integer<__int128> { enum { __value = 1 }; typedef __true_type __type; }; template<> struct __is_integer<unsigned __int128> { enum { __value = 1 }; typedef __true_type __type; };
^
...
code generation aborted due to compilation errors
[kernel] User Error: Failed to parse C++ file. See Clang messages for more information
[kernel] User Error: stopping on file "works.ii" that has errors.
[kernel] Frama-C aborted: invalid user input.