mirror of
https://github.com/vlang/v.git
synced 2025-09-16 02:49:31 -04:00
builder: add -fwrapv to fix UB overflow
This commit is contained in:
parent
80db36496b
commit
c6412597ab
@ -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'
|
||||
|
Loading…
x
Reference in New Issue
Block a user