ffi.copy/ffi.string fails with volatile-qualified char array

  • From: Philipp Kutin <philipp.kutin@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Mon, 4 Nov 2013 13:39:46 +0100

Hi,

using LuaJIT 2.0 git HEAD on Ubuntu 13.10, x86_64.

> av = ffi.new "volatile char [12]"
> aa = ffi.new "char [12]"
> ffi.copy(aa, av, 1)
stdin:1: bad argument #2 to 'copy' (cannot convert 'volatile char
[12]' to 'const void *')
> ffi.copy(av, aa, 1)
stdin:1: bad argument #1 to 'copy' (cannot convert 'volatile char
[12]' to 'void *')
> ffi.string(av)
stdin:1: bad argument #1 to 'string' (cannot convert 'volatile char
[12]' to 'const char *')

When manually casting 'av' to "void *", everything works though:

> ffi.copy(aa, ffi.cast("void *", av), 1)
(no error)

Background: I'm using 'volatile' merely as a marker for struct members
which get special treatment later (using ffi-reflect,
http://corsix.github.io). Thought I'd mention this because my reading
is that 'volatile' is supposed to be completely ignored by LuaJIT.

--Philipp

Other related posts: