Skip to content
Snippets Groups Projects
Commit b47a2a93 authored by Julien Signoles's avatar Julien Signoles
Browse files

Merge branch 'kostyantyn/bugfix/global-initialisers' into 'master'

Kostyantyn/bugfix/global initialisers

This is the fix for the issue `0001817`: `Literal strings in global arrays with compound initializers are not correctly initialized`. The change is as we have discussed during our meeting on the 7th of December. The gist of the fix as follows:

- Initialisers of all global variables are kept (instead of being removed), so as the code used for initialisations within the body of the `__e_acsl_memory_init`. 
- Literal strings used in initialisations are recorded via special global variables. 

The fix relies on the fact that a compiler will maintain only a single instance of a literal string, so recording a literal string once will cover all its uses. 

For example, strings pointed to by some global variables `A` and `B`:

```
...
const char *A = "X";
const char *B = "X";
...
```

will be captured by:

```
...
__e_acsl_literal_string = "X";
__store_block((void *)__e_acsl_literal_string,sizeof("X"));
__full_init((void *)__e_acsl_literal_string);
__literal_string((void *)__e_acsl_literal_string);
...
```

There are some test failures, as some code generation has changed. I have intentionally left them in for the fist time so you can see the tests that fail. If this patch is accepted I am happy to fix the test suite and add a couple of new tests to cover the issue. I have also attached a file with some examples of global initialisers for different cases which you may find useful.

[compound_initialiser.c](https://git.frama-c.com/frama-c/e-acsl/uploads/3599d1cbca9c790d6dd231d052ccf2f0/compound_initialiser.c)


See merge request !18
parents 331cfad5 d63bd270
No related branches found
No related tags found
No related merge requests found
Showing
with 987 additions and 10 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment