Skip to content

cast error with reference fields

ID0002396: This issue was created automatically from Mantis Issue 2396. Further discussion may take place here.


Id Project Category View Due Date Updated
ID0002396 Frama-C Plug-in > clang public 2018-08-24 2018-08-24
Reporter abhishek.anand.iitg@gmail.com Assigned To virgile Resolution open
Priority normal Severity minor Reproducibility always
Platform - OS manjaro OS Version 8/23/3018
Product Version Frama-C 17-Chlorine Target Version - Fixed in Version -

Description :

class B {
};

template <typename T>
class A {
public:
  T &x;
  A(T &y): x(y) {}
};

int main()
{
    B b;
    B & y=b;
    A<B> a(y);
}

I get the following error:

root@27db7a69b96a:/hostshare# frama-c -print refFieldBug.cpp                
[kernel] Parsing refFieldBug.cpp (external front-end)
Now output intermediate result
[kernel] refFieldBug.cpp:8: Failure: castTo struct _Z1B -> struct _Z1B *
[kernel] User Error: stopping on file "refFieldBug.cpp" that has errors.
[kernel] Frama-C aborted: invalid user inp

I don't see what could be the problem because the following succeeds:

class A {
public:
  T &x;
  A(T &y): x(y) {}
};

int main()
{
    int x=0;
    int & y=x;
    A<int> a(y);
}
Edited by Virgile Prevosto
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information