Skip to content

Build fails when using Clang 15 #7525

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
esteffin opened this issue Feb 7, 2023 · 5 comments
Closed

Build fails when using Clang 15 #7525

esteffin opened this issue Feb 7, 2023 · 5 comments

Comments

@esteffin
Copy link
Contributor

esteffin commented Feb 7, 2023

CBMC build fails when using Clang 15 (latest version of Clang released in September 2022) on Mac.

Multiple new warning are produced when building with Clang 15. This makes the build to fail as we use -Werror.

CBMC version: 5.76.1
Operating system: MacOS
Exact command line resulting in the issue: make
What behaviour did you expect: build succeed
What happened instead: build failure

@tautschnig
Copy link
Collaborator

Would you mind sharing the warnings so that they can be addressed, or are you already working on a PR to do so?

@esteffin
Copy link
Contributor Author

esteffin commented Feb 7, 2023

Unfortunately there are many warnings.

The first 2 to be encountered are:

/Users/esteffin/git/cbmc/src/goto-programs/osx_fat_reader.cpp:134:30: error: argument 'hdr' of type 'char[4]' with mismatched bound [-Werror,-Warray-parameter]
bool is_osx_mach_object(char hdr[4])
                             ^
/Users/esteffin/git/cbmc/src/goto-programs/osx_fat_reader.h:77:30: note: previously declared as 'char[8]' here
bool is_osx_mach_object(char hdr[8]);
                             ^
/Users/esteffin/git/cbmc/src/goto-programs/goto_trace.cpp:400:15: error: variable 'function_depth' set but not used [-Werror,-Wunused-but-set-variable]
  std::size_t function_depth = 0;
              ^

Addressing them unleashes many others such as:

  • 4 error: this style of line directive is a GNU extension [-Werror,-Wgnu-line-marker]
  • 14 error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes] in various files.

I don't know if fixing all those errors is enough though.

@tautschnig
Copy link
Collaborator

tautschnig commented Feb 7, 2023

Unfortunately there are many warnings.

So we should just go and fix them.

The first 2 to be encountered are:

/Users/esteffin/git/cbmc/src/goto-programs/osx_fat_reader.cpp:134:30: error: argument 'hdr' of type 'char[4]' with mismatched bound [-Werror,-Warray-parameter]
bool is_osx_mach_object(char hdr[4])
                             ^
/Users/esteffin/git/cbmc/src/goto-programs/osx_fat_reader.h:77:30: note: previously declared as 'char[8]' here
bool is_osx_mach_object(char hdr[8]);
                             ^

Good catch, this should be 4 in both cases. Fixed in #7526 .

/Users/esteffin/git/cbmc/src/goto-programs/goto_trace.cpp:400:15: error: variable 'function_depth' set but not used [-Werror,-Wunused-but-set-variable]
  std::size_t function_depth = 0;
              ^

This seems spurious?! We use that variable 3 lines later.

Addressing them unleashes many others such as:

* 4 `error: this style of line directive is a GNU extension [-Werror,-Wgnu-line-marker]`

Any example of this one?

* 14 `error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]` in various files.

Where is this showing up?

I don't know if fixing all those errors is enough though.

@esteffin
Copy link
Contributor Author

esteffin commented Feb 8, 2023

/Users/esteffin/git/cbmc/src/goto-programs/goto_trace.cpp:400:15: error: variable 'function_depth' set but not used [-Werror,-Wunused-but-set-variable]
  std::size_t function_depth = 0;

Yes, it is used 2 lines ago, but actually that variable is never read.
It is set to 0. at the beginning, then incremented/decremented with ++ and --, but never actually used or checked.

  • 4 error: this style of line directive is a GNU extension [-Werror,-Wgnu-line-marker]
  • 14 error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]

Both this 2 sets of errors are generated by src/ansi-c/library_check.sh and are related to __libcheck.c __libcheck.i and cprover_builtin_headers.h.

As for extra errors I cannot say as clearly the compilation stops at this point.

@tautschnig
Copy link
Collaborator

/Users/esteffin/git/cbmc/src/goto-programs/goto_trace.cpp:400:15: error: variable 'function_depth' set but not used [-Werror,-Wunused-but-set-variable]
  std::size_t function_depth = 0;

Yes, it is used 2 lines ago, but actually that variable is never read. It is set to 0. at the beginning, then incremented/decremented with ++ and --, but never actually used or checked.

Ah, thank you. Fixed in #7529.

tautschnig added a commit to tautschnig/cbmc that referenced this issue Feb 13, 2023
Clang 15 complains about GNU-style line markers (`# <number>` instead of
`#line <number>`), which we don't need to do anything about.

Fixes: diffblue#7525
tautschnig added a commit to tautschnig/cbmc that referenced this issue Feb 13, 2023
Clang 15 complains about GNU-style line markers (`# <number>` instead of
`#line <number>`), which we don't need to do anything about.

Fixes: diffblue#7525
tautschnig added a commit to tautschnig/cbmc that referenced this issue Feb 13, 2023
Clang 15 complains about GNU-style line markers (`# <number>` instead of
`#line <number>`), which we don't need to do anything about.

Fixes: diffblue#7525
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

2 participants