Skip to content

bugfix: symbol_factoryt must preserve struct_tag types [blocks: #3652] #3647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/ansi-c/c_nondet_symbol_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,17 @@ void symbol_factoryt::gen_nondet_init(
const std::size_t depth,
recursion_sett recursion_set)
{
const typet &type=ns.follow(expr.type());
const typet &type = expr.type();

if(type.id()==ID_pointer)
{
// dereferenced type
const pointer_typet &pointer_type=to_pointer_type(type);
const typet &subtype=ns.follow(pointer_type.subtype());
const typet &subtype = pointer_type.subtype();

if(subtype.id() == ID_struct)
if(subtype.id() == ID_struct_tag)
{
const struct_typet &struct_type = to_struct_type(subtype);
const irep_idt struct_tag = struct_type.get_tag();
const irep_idt struct_tag = to_struct_tag_type(subtype).get_identifier();

if(
recursion_set.find(struct_tag) != recursion_set.end() &&
Expand Down Expand Up @@ -153,14 +152,16 @@ void symbol_factoryt::gen_nondet_init(
assignments.add(std::move(null_check));
}
}
else if(type.id() == ID_struct)
else if(type.id() == ID_struct_tag)
{
const struct_typet &struct_type = to_struct_type(type);
const auto &struct_tag_type = to_struct_tag_type(type);

const irep_idt struct_tag = struct_type.get_tag();
const irep_idt struct_tag = struct_tag_type.get_identifier();

recursion_set.insert(struct_tag);

const auto &struct_type = to_struct_type(ns.follow_tag(struct_tag_type));

for(const auto &component : struct_type.components())
{
const typet &component_type = component.type();
Expand Down