translator/c/test/test_symbolic.py::test_offsetof
def test_offsetof():
STRUCT = lltype.GcStruct("s", ("x", lltype.Signed), ("y", lltype.Signed))
offsetx = llmemory.offsetof(STRUCT, 'x')
offsety = llmemory.offsetof(STRUCT, 'y')
def f():
s = lltype.malloc(STRUCT)
s.x = 1
adr = llmemory.cast_ptr_to_adr(s)
result = (adr + offsetx).signed[0]
(adr + offsety).signed[0] = 2
return result * 10 + s.y
> fn = compile(f, [])
translator\c\test\test_symbolic.py:18:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
translator\c\test\test_genc.py:110: in compile
t.annotate()
translator\interactive.py:83: in annotate
return self.driver.annotate()
translator\driver.py:108: in proc
return self.proceed(backend_goal)
translator\driver.py:569: in proceed
result = self._execute(goals, task_skip = self._maybe_skip())
translator\tool\taskengine.py:114: in _execute
res = self._do(goal, taskcallable, *args, **kwds)
translator\driver.py:278: in _do
res = func()
translator\driver.py:315: in task_annotate
s = annotator.build_types(self.entry_point, self.inputtypes)
annotator\annrpython.py:92: in build_types
return self.build_graph_types(flowgraph, inputs_s, complete_now=complete_now)
annotator\annrpython.py:140: in build_graph_types
self.complete()
annotator\annrpython.py:229: in complete
self.complete_pending_blocks()
annotator\annrpython.py:224: in complete_pending_blocks
self.processblock(graph, block)
annotator\annrpython.py:398: in processblock
self.flowin(graph, block)
annotator\annrpython.py:501: in flowin
self.consider_op(op)
annotator\annrpython.py:653: in consider_op
resultcell = op.consider(self)
flowspace\operation.py:104: in consider
return spec(annotator, *self.args)
annotator\unaryop.py:118: in simple_call_SomeObject
return s_func.call(argspec)
annotator\unaryop.py:987: in call
return bookkeeper.pbc_call(self, args)
annotator\bookkeeper.py:535: in pbc_call
results.append(desc.pycall(whence, args, s_previous_result, op))
annotator\description.py:285: in pycall
graph = self.specialize(inputcells, op)
annotator\description.py:279: in specialize
return self.specializer(self, inputcells, op)
annotator\specialize.py:370: in specialize_call_location
return maybe_star_args(funcdesc, (op,), args_s)
annotator\specialize.py:327: in maybe_star_args
return funcdesc.cachedgraph(key, builder=builder)
annotator\description.py:247: in cachedgraph
graph = self.buildgraph(alt_name, builder)
annotator\description.py:210: in buildgraph
graph = translator.buildflowgraph(self.pyobj)
translator\translator.py:78: in buildflowgraph
graph = build_flow(func)
flowspace\objspace.py:49: in build_flow
ctx.build_flow()
flowspace\flowcontext.py:405: in build_flow
self.record_block(block)
flowspace\flowcontext.py:413: in record_block
next_offset = self.handle_bytecode(next_offset)
flowspace\flowcontext.py:492: in handle_bytecode
offset = getattr(self, methodname)(oparg)
flowspace\flowcontext.py:670: in IMPORT_NAME
w_obj = self.import_name(modulename, glob, None, fromlist, level)
flowspace\flowcontext.py:660: in import_name
mod = __import__(name, glob, loc, frm, level)
rlib\_rsocket_rffi.py:1582: in <module>
_WSAGetLastError()
rtyper\lltypesystem\lltype.py:1384: in __call__
return callb(*args)
rtyper\lltypesystem\ll2ctypes.py:1339: in __call__
self.natural_arity)
rtyper\lltypesystem\ll2ctypes.py:1236: in get_ctypes_callable
symbolic=True)
translator\tool\cbuild.py:345: in compile_shared_lib
standalone=False))
translator\platform\__init__.py:57: in compile
ofiles = self._compile_o_files(cfiles, eci, standalone)
translator\platform\__init__.py:79: in _compile_o_files
ofiles.append(self._compile_c_file(self.cc, cfile, compile_args))
translator\platform\windows.py:290: in _compile_c_file
self._execute_c_compiler(cc, args, oname)
translator\platform\__init__.py:143: in _execute_c_compiler
self._handle_error(returncode, stdout, stderr, outname)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MsvcPlatform cc=cl.exe>, returncode = 3221225477, stdout = ''
stderr = ''
outname = local('d:\\systemtemp\\pytest\\usession-main-1375\\module_cache\\module_1.obj')
def _handle_error(self, returncode, stdout, stderr, outname):
if returncode != 0:
# Microsoft compilers write compilation errors to stdout
stderr = stdout + stderr
errorfile = outname.new(ext='errors')
errorfile.write(stderr, mode='wb')
if self.log_errors:
stderrlines = stderr.splitlines()
for line in stderrlines:
log.Error(line)
# ^^^ don't use ERROR, because it might actually be fine.
# Also, ERROR confuses lib-python/conftest.py.
> raise CompilationError(stdout, stderr)
E CompilationError: CompilationError(out="""
E """)
translator\platform\windows.py:319: CompilationError
---------- Captured stderr call ----------
[platform:msg] Updated environment with vsver 160, using x64 True
[flowgraph] (rpython.translator.c.test.test_genc:66)entry_point
[translation:info] Annotating&simplifying...
[c604061beebfb80] {translation-task
starting annotate
[translation:info] with policy: rpython.annotator.policy.AnnotatorPolicy
[platform:msg] Updated environment with vsver 160, using x64 True
[flowgraph] (rpython.translator.c.test.test_symbolic:11)f
[flowgraph] (rpython.flowspace.specialcase:76)rpython_print_item
[flowgraph] (rpython.translator.c.test.test_genc:39)llrepr_out
[flowgraph] (rpython.flowspace.specialcase:95)rpython_print_newline
[flowgraph] (rpython.flowspace.specialcase:85)rpython_print_end
[flowgraph] (rpython.rlib.rposix:500)write
[flowgraph] (rpython.rtyper.lltypesystem.rffi:1427)scoped_nonmovingbuffer.__init__
[flowgraph] (rpython.rtyper.lltypesystem.rffi:1431)scoped_nonmovingbuffer.__enter__
[flowgraph] (rpython.rtyper.lltypesystem.rffi:873)get_nonmovingbuffer_ll
[flowgraph] (rpython.rlib.objectmodel:315)we_are_translated_to_c
[flowgraph] (rpython.rtyper.lltypesystem.rstr:116)copy_string_to_raw
[flowgraph] (rpython.rtyper.lltypesystem.rstr:63)_get_raw_buf
[flowgraph] (rpython.rtyper.lltypesystem.rstr:57)_str_ofs
[flowgraph] (rpython.rtyper.lltypesystem.llmemory:411)sizeof
[flowgraph] (rpython.rtyper.lltypesystem.rffi:278)wrap_write
[flowgraph] (rpython.rtyper.lltypesystem.rffi:1433)scoped_nonmovingbuffer.__exit__
[flowgraph] (rpython.rtyper.lltypesystem.rffi:937)free_nonmovingbuffer_ll
[flowgraph] (rpython.rtyper.lltypesystem.rffi:3)ccall_wrap_write
[flowgraph] (rpython.rlib.rgil:160)release
[flowgraph] (rpython.rlib.rposix:151)_errno_before
[flowgraph] (rpython.rlib.rthread:349)getraw
[flowgraph] (rpython.rlib.rthread:349)getraw
[flowgraph] (rpython.rlib.rthread:349)getraw
[flowgraph] (rpython.rlib.rthread:349)getraw
[flowgraph] (rpython.rlib.rposix:170)_errno_after
[c60406490c38c80] translation-task}
builder: rpython-win-x86-64 build #442+
test: translator/c/test/test_symbolic.py::test_offsetof