mgehre / llvm-project

The home of the clang-based implementation of lifetime safety warnings.
39 stars 4 forks source link

Assert failure #57

Closed mgehre closed 5 years ago

mgehre commented 5 years ago

Assert with

class a;
class b {
  a operator*();
};
class a {};
class {
  b begin() { c; }
  void end();
  b c;
}
Xazax-hun commented 5 years ago

Is this the whole example? It does not compile for me ( e.g semicolon is missing for the last class).

mgehre commented 5 years ago

I just quickly copied the output from creduce, maybe something went wrong. Will check

mgehre commented 5 years ago

I can confirm that this crash when executed with /build/bin/clang-9 -fsyntax-only -Wlifetime source.cpp. Interestingly, without -Wlifetime, I get

/tmp/cmTryRunCommand-005ce2.reduced.cpp:7:15: warning: expression result unused [-Wunused-value]
  b begin() { c; }
              ^
/tmp/cmTryRunCommand-005ce2.reduced.cpp:7:18: warning: control reaches end of non-void function [-Wreturn-type]
  b begin() { c; }
                 ^
/tmp/cmTryRunCommand-005ce2.reduced.cpp:10:2: error: expected ';' after class
}
 ^
 ;
/tmp/cmTryRunCommand-005ce2.reduced.cpp:7:5: error: functions cannot be declared in an anonymous struct
  b begin() { c; }
    ^
/tmp/cmTryRunCommand-005ce2.reduced.cpp:8:8: error: functions cannot be declared in an anonymous struct
  void end();
       ^
/tmp/cmTryRunCommand-005ce2.reduced.cpp:9:5: error: anonymous struct cannot contain a private data member
  b c;
    ^
/tmp/cmTryRunCommand-005ce2.reduced.cpp:6:1: error: anonymous structs and classes must be class members

but with -Wlifetime I only see the warnings

warning: expression result unused [-Wunused-value]
warning: control reaches end of non-void function [-Wreturn-type]

and then the crash. I lifetime analysis runs before the analysis that emits the errors.

mgehre commented 5 years ago

Hm, this seems to be not a problem on the lifetime branch, only my local copy.