summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/semmagic.nim2
-rw-r--r--tests/misc/taddr.nim10
2 files changed, 11 insertions, 1 deletions
diff --git a/compiler/semmagic.nim b/compiler/semmagic.nim
index a8b0c9f18..8db62a9c8 100644
--- a/compiler/semmagic.nim
+++ b/compiler/semmagic.nim
@@ -73,7 +73,7 @@ proc semArrGet(c: PContext; n: PNode; flags: TExprFlags): PNode =
 proc semArrPut(c: PContext; n: PNode; flags: TExprFlags): PNode =
   # rewrite `[]=`(a, i, x)  back to ``a[i] = x``.
   let b = newNodeI(nkBracketExpr, n.info)
-  b.add(n[1].skipAddr)
+  b.add(n[1].skipHiddenAddr)
   for i in 2..<n.len-1: b.add(n[i])
   result = newNodeI(nkAsgn, n.info, 2)
   result[0] = b
diff --git a/tests/misc/taddr.nim b/tests/misc/taddr.nim
index 48d4928ac..64f95c7e3 100644
--- a/tests/misc/taddr.nim
+++ b/tests/misc/taddr.nim
@@ -273,6 +273,16 @@ proc test15939() = # bug #15939 (v2)
   else: # can't take address of cstring element in js
     when not defined(js): cstringTest()
 
+block: # bug #23499
+  template volatileStore[T](dest: ptr T, val: T) =
+    dest[] = val
+
+  proc foo =
+    var ctr = 0
+    volatileStore(addr ctr, 0)
+
+  foo()
+
 template main =
   # xxx wrap all other tests here like that so they're also tested in VM
   test14420()