Conversation
| | 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.
|
@certik The current diff does work fine for C and LLVM but fails in CPython because of two object comparisons. >>> import ctypes
>>> x = ctypes.c_void_p()
>>> y = ctypes.c_void_p()
>>> x == y
False |
|
Here you go, (lp) 18:59:02:~/lpython_project/lpython % python
Python 3.10.4 | packaged by conda-forge | (main, Mar 24 2022, 17:39:37) [Clang 12.0.1 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> x = ctypes.c_void_p()
>>> y = ctypes.c_void_p()
>>> x.value == y.value
True |
|
I see, we need to figure out a robust solution in CPython that will always work. If we have to do the |
|
Done in 1b162b9. |
|
Thanks @czgdp1807! |
Fixes #1781