Handle empty structs in the back-end (and a number of induced fixes)#2161
Handle empty structs in the back-end (and a number of induced fixes)#2161tautschnig merged 2 commits intodiffblue:developfrom
Conversation
bacc8c1 to
2b09684
Compare
51c11f8 to
02a13a2
Compare
allredj
left a comment
There was a problem hiding this comment.
This PR failed Diffblue compatibility checks (cbmc commit: 51c11f8).
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.
Common spurious failures:
- the cbmc commit has disappeared in the mean time (e.g. in a force-push)
- the author is not in the list of contributors (e.g. first-time contributors).
smowton
left a comment
There was a problem hiding this comment.
Couple of things to check, otherwise lgtm
src/util/pointer_offset_size.cpp
Outdated
| if(cellidx < 0 || !cellidx.is_long()) | ||
| const array_typet &array_type = to_array_type(source_type); | ||
|
|
||
| // no arrays of non-byte, zero-, or unknown-sized objects |
regression/systemc/Array4/test.desc
Outdated
| -- | ||
| ^warning: ignoring | ||
| -- | ||
| warning: ignoring byte_extract_little_endian |
There was a problem hiding this comment.
Do you mean this to be a comment?
There was a problem hiding this comment.
Yeah... along with the previous line that does seem a little bizaar.
|
|
||
| return object_rec(rest, pointer_type, tmp); | ||
| return plus_exprt( | ||
| address_of_exprt(deep_object.op0(), pointer_type(char_type())), |
There was a problem hiding this comment.
Doesn't this need an explicit typecast?
|
Needs to be rebased once #3185 is merged. |
martin-cs
left a comment
There was a problem hiding this comment.
A few minor comments. Shouldn't take much after the rebase.
regression/cbmc/Empty_struct2/main.c
Outdated
| #pragma pack(1) | ||
| struct S | ||
| { | ||
| int x; |
There was a problem hiding this comment.
If I was a complete sadist I might suggest making this an int8_t because then we have to deal with the packing rules around an empty structure. If y was one as well you'd hope that sizeof(struct S) would be sizeof(int8_t) * 2 rather than 2 (or 3) times the minimum alignment unit.
regression/systemc/Array4/test.desc
Outdated
| -- | ||
| ^warning: ignoring | ||
| -- | ||
| warning: ignoring byte_extract_little_endian |
There was a problem hiding this comment.
Yeah... along with the previous line that does seem a little bizaar.
| return src; | ||
| return plus_exprt( | ||
| address_of_exprt(deep_object.op0(), pointer_type(char_type())), | ||
| from_integer(pointer.offset / subtype_bytes, index_type())); |
src/util/pointer_offset_size.cpp
Outdated
|
|
||
| if( | ||
| offset * 8 >= m_offset_bits && m_offset_bits % 8 == 0 && | ||
| offset * 8 + target_size <= m_offset_bits + m_size) |
There was a problem hiding this comment.
8? Are we really hard-coded to have 8-bit bytes?
There was a problem hiding this comment.
Well, once #917 is merged (after me reworking some of it) that should no longer be the case.
There was a problem hiding this comment.
OK; I'll leave this one for now.
02a13a2 to
0d005d5
Compare
We now support pointers into structs with zero-sized members, which is a GCC extension that we otherwise do support.
0d005d5 to
d4296f1
Compare
allredj
left a comment
There was a problem hiding this comment.
✔️
Passed Diffblue compatibility checks (cbmc commit: d4296f1).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/89834675
I will need to break this PR apart, but I'll publish it in full for visibility. My original intent was just to fix the problem didn't handle empty structs (regression test included), which causes unnecessary failures in SV-COMP.
While I will split it up to enable reasonable reviewing, it should actually be clean and be ready for an evaluation against test-gen.