Skip to content

Error equality without matching types #162

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

Closed
mgudemann opened this issue Jul 2, 2016 · 2 comments
Closed

Error equality without matching types #162

mgudemann opened this issue Jul 2, 2016 · 2 comments

Comments

@mgudemann
Copy link
Contributor

For the following program

public class NullPointer5
{
  void f()
  {
    Object o = new Object();
    if(null == o)
      assert false;
    assert true;
  }
  void g()
  {
    Object o = new Object();
    if(o == null)
      assert false;
    assert true;
  }
}

the result of checking --function NullPointer5.g is ok, while --function NullPointer.f fails with the above error.

The same error is triggered with --function Inheritance3.f in

class Inheritance3
{
  class A
  {
  }
  class B extends A
  {
  }
  void f()
  {
    A a = new A();
    B b = new B();
    if(a == b)
      assert false;
    assert true;
  }
}
@smowton
Copy link
Contributor

smowton commented Aug 3, 2016

Addressed in smowton@5787def

This stemmed from indirecting via a local variable, which was given an inconsistent type (sometimes A* and sometimes void*). This commit simply treats pointer-typed locals as void* under all circumstances, since the same variable can be used with different types in different places in any case. The void* pointers are downcast to their proper types when needed (e.g. at method call sites, field accesses).

@smowton
Copy link
Contributor

smowton commented Aug 4, 2016

Fixed in Cristina's test_gen branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants