Closed
Description
Describe the issue
The following simple logging results in a compile error when
- the compiler is GCC
-c opt
is specified--copt="-DABSL_MIN_LOG_LEVEL=3"
is specified
LOG(DFATAL) << "msg";
$ bazel build //absl/log:globals_test -c opt --copt="-DABSL_MIN_LOG_LEVEL=3"
INFO: Analyzed target //absl/log:globals_test (0 packages loaded, 0 targets configured).
ERROR: /home/yukawa/work/abseil-cpp/absl/log/BUILD.bazel:408:8: Compiling absl/log/globals_test.cc failed: (Exit 1): gcc failed: error executing CppCompile command (from target //absl/log:globals_test) /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 66 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from ./absl/log/internal/log_impl.h:19,
from ./absl/log/log.h:200,
from absl/log/globals_test.cc:24:
absl/log/globals_test.cc: In member function 'virtual void {anonymous}::TestExitOnDFatal_OffTest_Test::TestBody()':
./absl/base/optimization.h:280:3: error: expected primary-expression before 'do'
280 | do { \
| ^~
./absl/log/internal/conditions.h:68:7: note: in definition of macro 'ABSL_LOG_INTERNAL_STATELESS_CONDITION'
68 | !(condition) ? (void)0 : ::absl::log_internal::Voidify()&&
| ^~~~~~~~~
./absl/log/internal/conditions.h:142:8: note: in expansion of macro 'ABSL_ASSUME'
142 | (ABSL_ASSUME(absl::kLogDebugFatal == absl::LogSeverity::kError || \
| ^~~~~~~~~~~
./absl/log/internal/log_impl.h:25:3: note: in expansion of macro 'ABSL_LOG_INTERNAL_CONDITION_DFATAL'
25 | ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, true) \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
./absl/log/log.h:209:23: note: in expansion of macro 'ABSL_LOG_INTERNAL_LOG_IMPL'
209 | #define LOG(severity) ABSL_LOG_INTERNAL_LOG_IMPL(_##severity)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
absl/log/globals_test.cc:141:5: note: in expansion of macro 'LOG'
141 | LOG(DFATAL) << "This should not be fatal";
| ^~~
./absl/base/optimization.h:280:3: error: expected ')' before 'do'
280 | do { \
| ^~
./absl/log/internal/conditions.h:68:7: note: in definition of macro 'ABSL_LOG_INTERNAL_STATELESS_CONDITION'
68 | !(condition) ? (void)0 : ::absl::log_internal::Voidify()&&
| ^~~~~~~~~
./absl/log/internal/conditions.h:142:8: note: in expansion of macro 'ABSL_ASSUME'
142 | (ABSL_ASSUME(absl::kLogDebugFatal == absl::LogSeverity::kError || \
| ^~~~~~~~~~~
./absl/log/internal/log_impl.h:25:3: note: in expansion of macro 'ABSL_LOG_INTERNAL_CONDITION_DFATAL'
25 | ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, true) \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
./absl/log/log.h:209:23: note: in expansion of macro 'ABSL_LOG_INTERNAL_LOG_IMPL'
209 | #define LOG(severity) ABSL_LOG_INTERNAL_LOG_IMPL(_##severity)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
absl/log/globals_test.cc:141:5: note: in expansion of macro 'LOG'
141 | LOG(DFATAL) << "This should not be fatal";
| ^~~
./absl/log/internal/conditions.h:142:7: note: to match this '('
142 | (ABSL_ASSUME(absl::kLogDebugFatal == absl::LogSeverity::kError || \
| ^
./absl/log/internal/conditions.h:68:7: note: in definition of macro 'ABSL_LOG_INTERNAL_STATELESS_CONDITION'
68 | !(condition) ? (void)0 : ::absl::log_internal::Voidify()&&
| ^~~~~~~~~
./absl/log/internal/log_impl.h:25:3: note: in expansion of macro 'ABSL_LOG_INTERNAL_CONDITION_DFATAL'
25 | ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, true) \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
./absl/log/log.h:209:23: note: in expansion of macro 'ABSL_LOG_INTERNAL_LOG_IMPL'
209 | #define LOG(severity) ABSL_LOG_INTERNAL_LOG_IMPL(_##severity)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
absl/log/globals_test.cc:141:5: note: in expansion of macro 'LOG'
141 | LOG(DFATAL) << "This should not be fatal";
| ^~~
./absl/base/optimization.h:282:5: error: expected ')' before 'while'
282 | } while (false)
| ^~~~~
./absl/log/internal/conditions.h:68:7: note: in definition of macro 'ABSL_LOG_INTERNAL_STATELESS_CONDITION'
68 | !(condition) ? (void)0 : ::absl::log_internal::Voidify()&&
| ^~~~~~~~~
./absl/log/internal/conditions.h:142:8: note: in expansion of macro 'ABSL_ASSUME'
142 | (ABSL_ASSUME(absl::kLogDebugFatal == absl::LogSeverity::kError || \
| ^~~~~~~~~~~
./absl/log/internal/log_impl.h:25:3: note: in expansion of macro 'ABSL_LOG_INTERNAL_CONDITION_DFATAL'
25 | ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, true) \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
./absl/log/log.h:209:23: note: in expansion of macro 'ABSL_LOG_INTERNAL_LOG_IMPL'
209 | #define LOG(severity) ABSL_LOG_INTERNAL_LOG_IMPL(_##severity)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
absl/log/globals_test.cc:141:5: note: in expansion of macro 'LOG'
141 | LOG(DFATAL) << "This should not be fatal";
| ^~~
./absl/log/internal/conditions.h:68:6: note: to match this '('
68 | !(condition) ? (void)0 : ::absl::log_internal::Voidify()&&
| ^
./absl/log/internal/conditions.h:141:3: note: in expansion of macro 'ABSL_LOG_INTERNAL_STATELESS_CONDITION'
141 | ABSL_LOG_INTERNAL_##type##_CONDITION( \
| ^~~~~~~~~~~~~~~~~~
./absl/log/internal/log_impl.h:25:3: note: in expansion of macro 'ABSL_LOG_INTERNAL_CONDITION_DFATAL'
25 | ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, true) \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
./absl/log/log.h:209:23: note: in expansion of macro 'ABSL_LOG_INTERNAL_LOG_IMPL'
209 | #define LOG(severity) ABSL_LOG_INTERNAL_LOG_IMPL(_##severity)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
absl/log/globals_test.cc:141:5: note: in expansion of macro 'LOG'
141 | LOG(DFATAL) << "This should not be fatal";
| ^~~
In file included from external/googletest+/googletest/include/gtest/gtest-printers.h:122,
from external/googletest+/googletest/include/gtest/gtest-matchers.h:49,
from external/googletest+/googletest/include/gtest/internal/gtest-death-test-internal.h:47,
from external/googletest+/googletest/include/gtest/gtest-death-test.h:43,
from external/googletest+/googletest/include/gtest/gtest.h:64,
from external/googletest+/googlemock/include/gmock/internal/gmock-internal-utils.h:51,
from external/googletest+/googlemock/include/gmock/gmock-actions.h:146,
from external/googletest+/googlemock/include/gmock/gmock.h:56,
from absl/log/globals_test.cc:18:
absl/log/globals_test.cc: In member function 'virtual void {anonymous}::TestDeathWhileExitOnDFatal_OnTest_Test::TestBody()':
./absl/base/optimization.h:280:3: error: expected primary-expression before 'do'
280 | do { \
| ^~
./absl/log/internal/conditions.h:141:3: note: in expansion of macro 'ABSL_LOG_INTERNAL_STATELESS_CONDITION'
141 | ABSL_LOG_INTERNAL_##type##_CONDITION( \
| ^~~~~~~~~~~~~~~~~~
./absl/log/internal/conditions.h:142:8: note: in expansion of macro 'ABSL_ASSUME'
142 | (ABSL_ASSUME(absl::kLogDebugFatal == absl::LogSeverity::kError || \
| ^~~~~~~~~~~
./absl/log/internal/log_impl.h:25:3: note: in expansion of macro 'ABSL_LOG_INTERNAL_CONDITION_DFATAL'
25 | ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, true) \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
./absl/log/log.h:209:23: note: in expansion of macro 'ABSL_LOG_INTERNAL_LOG_IMPL'
209 | #define LOG(severity) ABSL_LOG_INTERNAL_LOG_IMPL(_##severity)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
absl/log/globals_test.cc:151:24: note: in expansion of macro 'LOG'
151 | EXPECT_DEBUG_DEATH({ LOG(DFATAL) << "This should be fatal in debug mode"; },
| ^~~
./absl/base/optimization.h:280:3: error: expected ')' before 'do'
280 | do { \
| ^~
./absl/log/internal/conditions.h:141:3: note: in expansion of macro 'ABSL_LOG_INTERNAL_STATELESS_CONDITION'
141 | ABSL_LOG_INTERNAL_##type##_CONDITION( \
| ^~~~~~~~~~~~~~~~~~
./absl/log/internal/conditions.h:142:8: note: in expansion of macro 'ABSL_ASSUME'
142 | (ABSL_ASSUME(absl::kLogDebugFatal == absl::LogSeverity::kError || \
| ^~~~~~~~~~~
./absl/log/internal/log_impl.h:25:3: note: in expansion of macro 'ABSL_LOG_INTERNAL_CONDITION_DFATAL'
25 | ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, true) \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
./absl/log/log.h:209:23: note: in expansion of macro 'ABSL_LOG_INTERNAL_LOG_IMPL'
209 | #define LOG(severity) ABSL_LOG_INTERNAL_LOG_IMPL(_##severity)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
absl/log/globals_test.cc:151:24: note: in expansion of macro 'LOG'
151 | EXPECT_DEBUG_DEATH({ LOG(DFATAL) << "This should be fatal in debug mode"; },
| ^~~
./absl/log/internal/conditions.h:142:7: note: to match this '('
142 | (ABSL_ASSUME(absl::kLogDebugFatal == absl::LogSeverity::kError || \
| ^
./absl/log/internal/conditions.h:141:3: note: in expansion of macro 'ABSL_LOG_INTERNAL_STATELESS_CONDITION'
141 | ABSL_LOG_INTERNAL_##type##_CONDITION( \
| ^~~~~~~~~~~~~~~~~~
./absl/log/internal/log_impl.h:25:3: note: in expansion of macro 'ABSL_LOG_INTERNAL_CONDITION_DFATAL'
25 | ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, true) \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
./absl/log/log.h:209:23: note: in expansion of macro 'ABSL_LOG_INTERNAL_LOG_IMPL'
209 | #define LOG(severity) ABSL_LOG_INTERNAL_LOG_IMPL(_##severity)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
absl/log/globals_test.cc:151:24: note: in expansion of macro 'LOG'
151 | EXPECT_DEBUG_DEATH({ LOG(DFATAL) << "This should be fatal in debug mode"; },
| ^~~
./absl/base/optimization.h:282:5: error: expected ')' before 'while'
282 | } while (false)
| ^~~~~
./absl/log/internal/conditions.h:141:3: note: in expansion of macro 'ABSL_LOG_INTERNAL_STATELESS_CONDITION'
141 | ABSL_LOG_INTERNAL_##type##_CONDITION( \
| ^~~~~~~~~~~~~~~~~~
./absl/log/internal/conditions.h:142:8: note: in expansion of macro 'ABSL_ASSUME'
142 | (ABSL_ASSUME(absl::kLogDebugFatal == absl::LogSeverity::kError || \
| ^~~~~~~~~~~
./absl/log/internal/log_impl.h:25:3: note: in expansion of macro 'ABSL_LOG_INTERNAL_CONDITION_DFATAL'
25 | ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, true) \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
./absl/log/log.h:209:23: note: in expansion of macro 'ABSL_LOG_INTERNAL_LOG_IMPL'
209 | #define LOG(severity) ABSL_LOG_INTERNAL_LOG_IMPL(_##severity)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
absl/log/globals_test.cc:151:24: note: in expansion of macro 'LOG'
151 | EXPECT_DEBUG_DEATH({ LOG(DFATAL) << "This should be fatal in debug mode"; },
| ^~~
./absl/log/internal/conditions.h:68:6: note: to match this '('
68 | !(condition) ? (void)0 : ::absl::log_internal::Voidify()&&
| ^
./absl/log/internal/conditions.h:141:3: note: in expansion of macro 'ABSL_LOG_INTERNAL_STATELESS_CONDITION'
141 | ABSL_LOG_INTERNAL_##type##_CONDITION( \
| ^~~~~~~~~~~~~~~~~~
./absl/log/internal/log_impl.h:25:3: note: in expansion of macro 'ABSL_LOG_INTERNAL_CONDITION_DFATAL'
25 | ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, true) \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
./absl/log/log.h:209:23: note: in expansion of macro 'ABSL_LOG_INTERNAL_LOG_IMPL'
209 | #define LOG(severity) ABSL_LOG_INTERNAL_LOG_IMPL(_##severity)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
absl/log/globals_test.cc:151:24: note: in expansion of macro 'LOG'
151 | EXPECT_DEBUG_DEATH({ LOG(DFATAL) << "This should be fatal in debug mode"; },
| ^~~
At global scope:
cc1plus: note: unrecognized command-line option '-Wno-unused-private-field' may have been intended to silence earlier diagnostics
Target //absl/log:globals_test failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.749s, Critical Path: 0.65s
INFO: 4 processes: 1 action cache hit, 2 internal, 2 linux-sandbox.
ERROR: Build did NOT complete successfully
Steps to reproduce the problem
git clone https://github.com/abseil/abseil-cpp
cd abseil-cpp
git checkout d5bafc01dd2b538075ab6c4573986ea28e96c1fb
bazel build //absl/log:globals_test -c opt --copt="-DABSL_MIN_LOG_LEVEL=3"
What version of Abseil are you using?
$ git rev-parse HEAD
d5bafc01dd2b538075ab6c4573986ea28e96c1fb
What operating system and version are you using?
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04.1 LTS
Release: 24.04
Codename: noble
What compiler and version are you using?
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-gnu/13/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 13.3.0-6ubuntu2~24.04' --with-bugurl=file:///usr/share/doc/gcc-13/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-13 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-libstdcxx-backtrace --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-13-fG75Ri/gcc-13-13.3.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-13-fG75Ri/gcc-13-13.3.0/debian/tmp-gcn/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.3.0 (Ubuntu 13.3.0-6ubuntu2~24.04)
What build system are you using?
$ bazel --version
bazel 8.0.1
Additional context
The issue disappears if we remove ABSL_ASSUME(...),
as follows.
diff --git a/absl/log/internal/conditions.h b/absl/log/internal/conditions.h
index 9dc15db4..c302f261 100644
--- a/absl/log/internal/conditions.h
+++ b/absl/log/internal/conditions.h
@@ -139,9 +139,7 @@
: false))
#define ABSL_LOG_INTERNAL_CONDITION_DFATAL(type, condition) \
ABSL_LOG_INTERNAL_##type##_CONDITION( \
- (ABSL_ASSUME(absl::kLogDebugFatal == absl::LogSeverity::kError || \
- absl::kLogDebugFatal == absl::LogSeverity::kFatal), \
- (condition) && \
+ ((condition) && \
(::absl::kLogDebugFatal >= \
static_cast<::absl::LogSeverity>(ABSL_MIN_LOG_LEVEL) || \
(::absl::kLogDebugFatal == ::absl::LogSeverity::kFatal && \
abseil-cpp/absl/log/internal/conditions.h
Lines 140 to 148 in d5bafc0
The issue is not reproducible with Ubuntu clang version 18.1.3
. The issue is specific to GCC.
Metadata
Metadata
Assignees
Labels
No labels