Uh oh!
There was an error while loading. Please reload this page.
Support nullptr testing - #1805
Conversation
Uh oh!
There was an error while loading. Please reload this page.
| | StringOrd(expr arg, ttype type, expr? value) | ||
| | StringChr(expr arg, ttype type, expr? value) | ||
| | CPtrCompare(expr left, cmpop op, expr right, ttype type, expr? value) |
There was a problem hiding this comment.
The cmpop has various things like >. What does that mean for CPtr? I think we only want == and !=.
There was a problem hiding this comment.
C has pointer comparisons for different cmpop as seen here.
There was a problem hiding this comment.
I see. We can allow it in ASR, since eventually we want to have a C frontend too. But in LPython I would mainly support == and != for now for CPtr. The other ones we can, but don't have to right now.
Uh oh!
There was an error while loading. Please reload this page.
Smit-create
commented
May 16, 2023
@certik The current diff does work fine for C and LLVM but fails in CPython because of two object comparisons. >>>importctypes>>>x=ctypes.c_void_p()
>>>y=ctypes.c_void_p()
>>>x==yFalse |
czgdp1807
commented
May 16, 2023
Here you go, (lp) 18:59:02:~/lpython_project/lpython%pythonPython3.10.4|packagedbyconda-forge| (main, Mar242022, 17:39:37) [Clang12.0.1 ] ondarwinType"help", "copyright", "credits"or"license"formoreinformation.
>>>importctypes>>>x=ctypes.c_void_p()
>>>y=ctypes.c_void_p()
>>>x.value==y.valueTrue |
certik
commented
May 16, 2023
I see, we need to figure out a robust solution in CPython that will always work. If we have to do the |
czgdp1807
commented
May 16, 2023
Done in 1b162b9. |
Smit-create
commented
May 16, 2023
Thanks @czgdp1807! |
Fixes#1781