Skip to content

E-ACSL: compilation fail: generated functions doesn't have static inline attributes

ID0002304: This issue was created automatically from Mantis Issue 2304. Further discussion may take place here.


Id Project Category View Due Date Updated
ID0002304 Frama-C Plug-in > E-ACSL public 2017-05-29 2017-12-06
Reporter evdenis Assigned To signoles Resolution fixed
Priority normal Severity major Reproducibility always
Platform - OS - OS Version -
Product Version Frama-C 14-Silicon Target Version - Fixed in Version Frama-C 16-Sulfur

Description :

The absence of static inline attributes forces optional dependencies to be strict. This leads to undefined reference errors during compilation.

Test (inline.c): extern int do_mmap(int *a);

static inline int test_extern(int *a) // Static inline { return do_mmap(a); }

int main(void) { return 0; }

GCC Run: $ gcc ./inline.c # There is no error about do_mmap $ echo $? 0

Generated Code (inline_generated.c): ... /*@ assigns \result, *a; assigns \result \from *a; assigns *a \from *a; */ int __gen_e_acsl_do_mmap(int *a); ... __inline static int test_extern(int a) { int tmp; /@ behavior pre_do_mmap: assigns tmp, *a; assigns tmp \from *a; assigns *a \from *a; / tmp = __gen_e_acsl_do_mmap(a); return tmp; } ... /@ assigns \result, *a; assigns \result \from *a; assigns *a \from *a; */ int __gen_e_acsl_do_mmap(int *a) // <== ERROR { int __retres; __retres = do_mmap(a); return __retres; }

GCC Run: $ gcc ./inline_generated.c /tmp/cczBUd0r.o: In function __gen_e_acsl_do_mmap': inline_generated.c:(.text+0x24): undefined reference to do_mmap' collect2: error: ld returned 1 exit status

Additional Information :

Quickfix: diff --git a/dup_functions.ml b/dup_functions.ml index 5774115..3b25fde 100644 --- a/dup_functions.ml +++ b/dup_functions.ml @@ -197,6 +197,8 @@ let dup_global loc old_prj spec bhv kf vi new_vi = let name = vi.vname in Options.feedback ~dkey ~level:2 "entering in function %s" name; let fundec = dup_fundec loc spec bhv kf vi new_vi in

  • fundec.svar.vinline <- true;
  • fundec.svar.vstorage <- Static; let fct = Definition(fundec, loc) in let new_spec = fundec.sspec in let new_kf = { fundec = fct; spec = new_spec } in

Steps To Reproduce :

frama-c -e-acsl-prepare -rte -rte-precond ./inline.c -then -e-acsl -then-last -print > inline_generated.c gcc inline_generated.c

Attachments

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information