-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Example
template works(pos, member) =
echo offsetof(type(pos[]), member)
template broken[T](pos: ptr T, member) =
echo offsetof(T, member)
type O = object
f: int
var o = O()
var po = addr o
works(po, f) # prints 0
broken(po, f) # prints 140695517813200Current Output
0
140695517813200
or this compiler crash if compiler is built without -d:danger:
nim/compiler/nim.nim(125) nim
nim/compiler/nim.nim(84) handleCmdLine
nim/compiler/main.nim(242) mainCommand
nim/compiler/main.nim(213) compileToBackend
nim/compiler/main.nim(90) commandCompileToC
nim/compiler/modules.nim(177) compileProject
nim/compiler/modules.nim(97) compileModule
nim/compiler/passes.nim(180) processModule
nim/compiler/passes.nim(73) processTopLevelStmt
nim/compiler/sem.nim(606) myProcess
nim/compiler/sem.nim(574) semStmtAndGenerateGenerics
nim/compiler/semstmts.nim(2292) semStmt
nim/compiler/semexprs.nim(1042) semExprNoType
nim/compiler/semexprs.nim(2892) semExpr
nim/compiler/semstmts.nim(2234) semStmtList
nim/compiler/semexprs.nim(2780) semExpr
nim/compiler/semexprs.nim(1024) semDirectOp
nim/compiler/semexprs.nim(907) afterCallActions
nim/compiler/semexprs.nim(38) semTemplateExpr
nim/compiler/sem.nim(405) semAfterMacroCall
nim/compiler/semstmts.nim(2292) semStmt
nim/compiler/semexprs.nim(1042) semExprNoType
nim/compiler/semexprs.nim(2892) semExpr
nim/compiler/semstmts.nim(2234) semStmtList
nim/compiler/semexprs.nim(2794) semExpr
nim/compiler/semexprs.nim(2332) semMagic
nim/compiler/semexprs.nim(1023) semDirectOp
nim/compiler/semexprs.nim(859) semOverloadedCallAnalyseEffects
nim/compiler/semcall.nim(566) semOverloadedCall
nim/compiler/semcall.nim(360) resolveOverloads
nim/compiler/semcall.nim(95) pickBestCandidate
nim/compiler/sigmatch.nim(2536) matches
nim/compiler/sigmatch.nim(2469) matchesAux
nim/compiler/sigmatch.nim(2280) prepareOperand
nim/compiler/semexprs.nim(53) semOperand
nim/compiler/semexprs.nim(2805) semExpr
nim/compiler/semexprs.nim(1024) semDirectOp
nim/compiler/semexprs.nim(907) afterCallActions
nim/compiler/semexprs.nim(38) semTemplateExpr
nim/compiler/sem.nim(443) semAfterMacroCall
nim/compiler/semexprs.nim(2892) semExpr
nim/compiler/semstmts.nim(2234) semStmtList
nim/compiler/semexprs.nim(2794) semExpr
nim/compiler/semexprs.nim(2332) semMagic
nim/compiler/semexprs.nim(1024) semDirectOp
nim/compiler/semexprs.nim(914) afterCallActions
nim/compiler/sizealignoffsetimpl.nim(499) magicsAfterOverloadResolution
nim/lib/system/fatal.nim(53) sysFatal
Error: unhandled exception: 'sym' is not accessible using discriminant 'kind' of type 'TNode' [FieldDefect]
(expected a sym, but got an ident 'f')
Expected Output
0
0
Tested on 4bfc5a9
Metadata
Metadata
Assignees
Labels
No labels