Skip to content

Commit

Permalink
builder: add -fwrapv to fix UB overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
medvednikov committed Aug 29, 2023
1 parent 80db364 commit c641259
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions vlib/v/builder/cc.v
Expand Up @@ -206,6 +206,13 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) {
|| ccoptions.guessed_compiler == 'msvc'
ccoptions.is_cc_clang = ccompiler_file_name.contains('clang')
|| ccoptions.guessed_compiler == 'clang'

// Add -fwrapv to handle UB overflows
if (ccoptions.is_cc_gcc || ccoptions.is_cc_clang || ccoptions.is_cc_tcc)
&& v.pref.os in [.macos, .linux, .windows] {
ccoptions.args << '-fwrapv'
}

// For C++ we must be very tolerant
if ccoptions.guessed_compiler.contains('++') {
ccoptions.args << '-fpermissive'
Expand Down

0 comments on commit c641259

Please sign in to comment.