Java Cast Error
See original GitHub issueWhen loading the following C code with the cpg, I get an Exception:
int main() {
size_t count = (size_t)(42);
return 0;
}
java.lang.ClassCastException: class
org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTUnaryExpression cannot be cast to class
org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression
Whereas the following code can be loaded successfully:
int main() {
size_t count = (size_t)42;
return 0;
}
I’m using the cpg and cpg-neo4j from master branch. Can you reproduce the error?
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (10 by maintainers)
Top Results From Across the Web
Explanation of ClassCastException in Java - Stack Overflow
A class cast exception is thrown by Java when you try to cast an Object of one data type to another.
Read more >How to Solve Class Cast Exceptions in Java? - GeeksforGeeks
1. Checked Exception: The exception which is checked by the compiler for the smooth execution of the program at runtime is called a...
Read more >How to Solve ClassCastException in Java - Rollbar
It is a runtime exception that occurs when the application code attempts to cast an object to another class of which the original...
Read more >ClassCastException (Java Platform SE 7 ) - Oracle Help Center
Thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an instance. For...
Read more >How to fix java.lang.classcastexception - Net-Informations.Com
classcastexception occurs when you try to cast an instance of an Object to a type that it is not. Casting only works when...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If A is a function pointer,
(A)(B)
can very well be a call. It’s not more or less unusual to write a call that way than writing a cast like thatThanks for the fix! Works for me. Yes, the intention was a cast. With includes enabled, the cpg is doing this correctly in both situations. But without the include, we have encountered a C language ambiguity ^^ Interpreting
(A)(B)
as a function callA(B)
seems to me like an unusual coding style. Changing the heuristic to interpret this as a cast would be a better fit in my opinion.