Skip to content

Compiling assert(expr) yields redundant if #755

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

Closed
tautschnig opened this issue Apr 4, 2017 · 2 comments
Closed

Compiling assert(expr) yields redundant if #755

tautschnig opened this issue Apr 4, 2017 · 2 comments

Comments

@tautschnig
Copy link
Collaborator

I haven't yet done any bisect, but just noticed that assert(expr) now yields both an assert instruction as well as an if:

$ cat as.c
#include <assert.h>

int main(int argc, char* argv[])
{
  assert(0);
  return 0;
}
$ cbmc/cbmc --show-goto-functions as.c
[...]
main /* main */
        // 0 file as.c line 5 function main
        ASSERT !((signed long int)!(0 != 0) != 0l) // assertion 0
        // 1 file as.c line 5 function main
        IF (signed long int)!(0 != 0) != 0l THEN GOTO 1
        // 2 file as.c line 6 function main
     1: main#return_value = 0;
        // 3 file as.c line 7 function main
        END_FUNCTION

This is on OS X, but the original observation was triggered on Linux.

@tautschnig
Copy link
Collaborator Author

It might actually not be a change in our code base. Doing gcc -E as.c:
Some rather ancient C library:

((0) ? (void) (0) : __assert_fail ("0", "as.c", 5, __PRETTY_FUNCTION__));

whereas recent ones have:

(__builtin_expect(!(0), 0) ? __assert_rtn(__func__, "as.c", 5, "0") : (void)0);

@tautschnig
Copy link
Collaborator Author

For the record: this is due to 6129d36. I'm working on a workaround.

tautschnig added a commit to tautschnig/cbmc that referenced this issue Jun 8, 2017
tautschnig added a commit to tautschnig/cbmc that referenced this issue Jan 9, 2018
hannes-steffenhagen-diffblue pushed a commit to hannes-steffenhagen-diffblue/cbmc that referenced this issue Jan 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant