Skip to content

Commit ce1ce13

Browse files
Merge pull request #7542 from thomasspriggs/tas/gcc12
Fix building with gcc 12
2 parents 5cb6441 + bfb968b commit ce1ce13

File tree

4 files changed

+73
-12
lines changed

4 files changed

+73
-12
lines changed

.github/workflows/pull-request-checks.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,59 @@ jobs:
365365
- name: Run tests
366366
run: cd build; ctest . -V -L CORE -j2
367367

368+
# This job takes approximately 26 to 46 minutes
369+
check-ubuntu-22_04-cmake-gcc-12:
370+
runs-on: ubuntu-22.04
371+
steps:
372+
- uses: actions/checkout@v3
373+
with:
374+
submodules: recursive
375+
- name: Fetch dependencies
376+
env:
377+
# This is needed in addition to -yq to prevent apt-get from asking for
378+
# user input
379+
DEBIAN_FRONTEND: noninteractive
380+
run: |
381+
sudo apt-get update
382+
sudo apt-get install --no-install-recommends -yq cmake ninja-build gcc-12 gdb g++-12 maven flex bison libxml2-utils dpkg-dev ccache doxygen z3
383+
- name: Confirm z3 solver is available and log the version installed
384+
run: z3 --version
385+
- name: Download cvc-5 from the releases page and make sure it can be deployed
386+
run: |
387+
wget -O cvc5 https://github.com/cvc5/cvc5/releases/download/cvc5-${{env.cvc5-version}}/cvc5-Linux
388+
chmod u+x cvc5
389+
mv cvc5 /usr/local/bin
390+
cvc5 --version
391+
- name: Prepare ccache
392+
uses: actions/cache@v3
393+
with:
394+
path: .ccache
395+
key: ${{ runner.os }}-22.04-Release-gcc-12-${{ github.ref }}-${{ github.sha }}-PR
396+
restore-keys: |
397+
${{ runner.os }}-22.04-Release-gcc-12-${{ github.ref }}
398+
${{ runner.os }}-22.04-Release-gcc-12
399+
- name: ccache environment
400+
run: |
401+
echo "CCACHE_BASEDIR=$PWD" >> $GITHUB_ENV
402+
echo "CCACHE_DIR=$PWD/.ccache" >> $GITHUB_ENV
403+
- name: Configure using CMake
404+
run: cmake -S . -Bbuild -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/bin/gcc-12 -DCMAKE_CXX_COMPILER=/usr/bin/g++-12
405+
- name: Check that doc task works
406+
run: ninja -C build doc
407+
- name: Zero ccache stats and limit in size
408+
run: ccache -z --max-size=500M
409+
- name: Build with Ninja
410+
run: ninja -C build -j2
411+
- name: Print ccache stats
412+
run: ccache -s
413+
- name: Check if package building works
414+
run: |
415+
cd build
416+
ninja package
417+
ls *.deb
418+
- name: Run tests
419+
run: cd build; ctest . -V -L CORE -j2
420+
368421
# This job takes approximately 5 to 24 minutes
369422
check-ubuntu-20_04-cmake-gcc-KNOWNBUG:
370423
runs-on: ubuntu-20.04

jbmc/src/java_bytecode/remove_exceptions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class remove_exceptionst
9595
message_handlert &_message_handler)
9696
: symbol_table(_symbol_table),
9797
class_hierarchy(_class_hierarchy),
98-
function_may_throw(_function_may_throw),
98+
function_may_throw(std::move(_function_may_throw)),
9999
remove_added_instanceof(_remove_added_instanceof),
100100
message_handler(_message_handler)
101101
{

src/cprover/cprover_parse_options.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,17 +218,15 @@ int cprover_parse_optionst::main()
218218
return CPROVER_EXIT_SUCCESS;
219219
}
220220

221-
// gcc produces a spurious warning on optionalt<irep_idt>.
222-
// This will likely go away once we use std::optional<irep_idt>.
223-
// To make clang ignore the pragma, we need to guard it with an ifdef.
224-
#pragma GCC diagnostic push
225-
#ifndef __clang__
226-
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
227-
#endif
228-
optionalt<irep_idt> contract = cmdline.isset("contract")
229-
? irep_idt(cmdline.get_value("contract"))
230-
: optionalt<irep_idt>{};
231-
#pragma GCC diagnostic pop
221+
// gcc produces a spurious warning for optionalt<irep_idt> if initialised
222+
// with ternary operator. Initialising with an immediately invoked lamda
223+
// avoids this.
224+
const auto contract = [&]() -> optionalt<irep_idt> {
225+
if(cmdline.isset("contract"))
226+
return {cmdline.get_value("contract")};
227+
else
228+
return {};
229+
}();
232230

233231
if(cmdline.isset("smt2") || cmdline.isset("text") || variable_encoding)
234232
{

src/goto-instrument/unwindset.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,19 @@ void unwindsett::parse_unwindset_one_loop(
172172
uw = unsafe_string2unsigned(uw_string);
173173

174174
if(thread_nr.has_value())
175+
{
176+
// Work around spurious GCC 12 warning about thread_nr being uninitialised.
177+
#pragma GCC diagnostic push
178+
#ifndef __clang__
179+
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
180+
#endif
175181
thread_loop_map[std::pair<irep_idt, unsigned>(id, *thread_nr)] = uw;
182+
#pragma GCC diagnostic pop
183+
}
176184
else
185+
{
177186
loop_map[id] = uw;
187+
}
178188
}
179189
}
180190

0 commit comments

Comments
 (0)