Skip to content

Commit

Permalink
enable a couple of compiler warnings
Browse files Browse the repository at this point in the history
enable -Wnonnull-compare and -Wnoexcept-type
  • Loading branch information
dspeterson committed Aug 15, 2021
1 parent 5588e8c commit 3724ca0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
16 changes: 7 additions & 9 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ prog_libs = {'pthread', 'dl', 'rt', 'z'}
env.Append(CFLAGS=['-Wwrite-strings'],
CCFLAGS=['-Wall', '-Wextra', '-Werror', '-Wformat=2', '-Winit-self',
'-Wunused-parameter', '-Wshadow', '-Wpointer-arith',
'-Wcast-align', '-Wlogical-op', '-Wno-nonnull-compare'],
'-Wcast-align', '-Wlogical-op'],
CPPDEFINES=[('SRC_ROOT', '\'"' + src.abspath + '"\'')],
CPPPATH=[src, tclap, gtestincdir],
CXXFLAGS=['-std=c++2a', '-Wold-style-cast', '-Wno-noexcept-type'],
CXXFLAGS=['-std=c++2a', '-Wold-style-cast'],
DEP_SUFFIXES=['.cc', '.cpp', '.c', '.cxx', '.c++', '.C'],
PROG_LIBS=[lib for lib in prog_libs],
TESTSUFFIX='.test',
Expand All @@ -176,8 +176,7 @@ def set_debug_options():
# libasan on RHEL, Fedora, and CentOS).
env.AppendUnique(CCFLAGS=['-g3', '-ggdb', '-fno-omit-frame-pointer',
'-fvisibility=hidden'])
env.AppendUnique(CXXFLAGS=['-D_GLIBCXX_DEBUG',
'-D_GLIBCXX_DEBUG_PEDANTIC',
env.AppendUnique(CXXFLAGS=['-D_GLIBCXX_DEBUG', '-D_GLIBCXX_DEBUG_PEDANTIC',
'-DTRACK_FILE_DESCRIPTORS'])
env.AppendUnique(LINKFLAGS=['-rdynamic'])

Expand All @@ -187,15 +186,14 @@ def set_debug_options():


def set_release_options():
# Enabling link-time optimizations breaks the build on Ubuntu 15, so for
# now we avoid enabling them. What a chore it is to get stuff to build on
# multiple platforms. :-(
# Enabling link-time optimizations breaks the build on some platforms, so
# for now we avoid enabling them. What a chore it is to get stuff to build
# on multiple platforms. :-(

env.AppendUnique(CCFLAGS=['-O2', '-DNDEBUG', '-Wno-unused',
'-Wno-unused-parameter', '-fvisibility=hidden'])

# Unfortunately this is needed to prevent spurious build errors on Ubuntu
# 14. :-(
# Unfortunately this is needed to prevent errors on Ubuntu.
env.AppendUnique(CPPFLAGS=['-U_FORTIFY_SOURCE'])

env.AppendUnique(LINKFLAGS=['-rdynamic'])
Expand Down
3 changes: 3 additions & 0 deletions src/base/error_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ static void WriteFatalMsgToStderr(const char *msg) noexcept {
iov[0].iov_len = std::strlen(msg);
iov[1].iov_base = const_cast<char *>("\n");
iov[1].iov_len = 1;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-result"
writev(stderr_fd, iov, sizeof(iov) / sizeof(*iov));
#pragma GCC diagnostic pop
}

static void EmitStackTrace(const char *msg) {
Expand Down

0 comments on commit 3724ca0

Please sign in to comment.