-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
conv
needs to be picky about aliases and introduces a temp for addr conv
#24818
Conversation
so, taking strict aliasing into account, the correct code to generate in c is something like: void main(NU64* v) {
unsigned long long tmp = (unsigned long long)(*v);
foo(&tmp);
*v = tmp
} is that the outcome after this PR? ie casting the pointer itself will lead to UB. |
Okay, I was going to generate a temp for |
In this PR, It introduces a temp for the case of T1_ = ((unsigned long long) (m_1));
foo(((&T1_))); The rest could be resolved in the future It requires #24817 to make CI green |
conv
needs to be picky about aliasesconv
needs to be picky about aliases and introduces a temp for addr conv
compiler/ccgexprs.nim
Outdated
@@ -962,6 +962,11 @@ proc cowBracket(p: BProc; n: PNode) = | |||
proc cow(p: BProc; n: PNode) {.inline.} = | |||
if n.kind == nkHiddenAddr: cowBracket(p, n[0]) | |||
|
|||
template noSomeCast(e: PNode): bool = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is noSomeCast
? Name it ignoreConv
or something that describes what this does.
Thanks for your hard work on this PR! Hint: mm: orc; opt: speed; options: -d:release |
…r conv` (#24818) ref #24817 ref #24815 ref status-im/nim-eth#784 ```nim {.emit:""" void foo(unsigned long long* x) { } """.} proc foo(x: var culonglong) {.importc: "foo", nodecl.} proc main(x: var uint64) = # var s: culonglong = u # TODO: var m = uint64(12) # var s = culonglong(m) foo(culonglong m) var u = uint64(12) main(u) ``` Notes that this code gives incompatible errors in 2.0.0, 2.2.0 and the devel branch. With this PR, `conv` is kept, but it seems to go back to #24807 (cherry picked from commit f9c8775)
ref #24817
ref #24815
ref status-im/nim-eth#784
Notes that this code gives incompatible errors in 2.0.0, 2.2.0 and the devel branch. With this PR,
conv
is kept, but it seems to go back to #24807