Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion regression/cbmc/Linking4/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE broken-smt-backend
CORE
link1.c
link2.c
^EXIT=0$
Expand Down
9 changes: 9 additions & 0 deletions regression/linking-goto-binaries/array_size/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "supp.h"
#include <assert.h>

int main()
{
int entry = A[1];
assert(entry == 42);
return 0;
}
3 changes: 3 additions & 0 deletions regression/linking-goto-binaries/array_size/supp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "supp.h"

int A[2] = {0, 42};
6 changes: 6 additions & 0 deletions regression/linking-goto-binaries/array_size/supp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef SUPP_H
#define SUPP_H

extern int A[];

#endif // SUPP_H
9 changes: 9 additions & 0 deletions regression/linking-goto-binaries/array_size/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CORE
main.c
supp.c
^EXIT=0$
^SIGNAL=0$
\[main.assertion.1\] line [0-9]+ assertion entry == 42: SUCCESS
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
15 changes: 7 additions & 8 deletions regression/linking-goto-binaries/chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@ set -e
goto_cc=$1
cbmc=$2
is_windows=$3
entry_point='generated_entry_function'

main=${*:$#}
main=${main%.c}
args=${*:4:$#-4}
next=${args%.c}

if [[ "${is_windows}" == "true" ]]; then
$goto_cc "${main}.c"
$goto_cc "${next}.c"
mv "${main}.exe" "${main}.gb"
mv "${next}.exe" "${next}.gb"
$goto_cc /c "${main}.c" "/Fo${main}.gb"
$goto_cc /c "${next}.c" "/Fo${next}.gb"
$goto_cc "${main}.gb" "${next}.gb" "/Fefinal.gb"
else
$goto_cc -o "${main}.gb" "${main}.c"
$goto_cc -o "${next}.gb" "${next}.c"
$goto_cc -c -o "${main}.gb" "${main}.c"
$goto_cc -c -o "${next}.gb" "${next}.c"
$goto_cc "${main}.gb" "${next}.gb" -o "final.gb"
fi

$cbmc "${main}.gb" "${next}.gb"
$cbmc "final.gb"
9 changes: 7 additions & 2 deletions src/linking/linking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ bool casting_replace_symbolt::replace_symbol_expr(symbol_exprt &s) const

const exprt &e = it->second;

typet type = s.type();
static_cast<exprt &>(s) = typecast_exprt::conditional_cast(e, type);
if(e.type().id() != ID_array)
{
typet type = s.type();
static_cast<exprt &>(s) = typecast_exprt::conditional_cast(e, type);
}
else
static_cast<exprt &>(s) = e;

return false;
}
Expand Down