Getting error: value of type 'void' is not contextually convertible to 'bool'

Hi guys,

Using clang (13 && 14 && 15) on FreeBSD 13.1 I am getting the following errors.

xxx/blender/intern/cycles/blender/display_driver.cpp:562:7: error: value of type 'void' is not contextually convertible to 'bool'
  if (!DCHECK_NOTNULL(tile.buffer_object.gpu_pixel_buffer)) {
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
xxx/blender/intern/cycles/blender/display_driver.cpp:616:7: error: value of type 'void' is not contextually convertible to 'bool'
  if (!DCHECK_NOTNULL(pix_buf)) {
      ^~~~~~~~~~~~~~~~~~~~~~~~
xxx/blender/intern/cycles/blender/display_driver.cpp:630:7: error: value of type 'void' is not contextually convertible to 'bool'
  if (!DCHECK_NOTNULL(pix_buf)) {
      ^~~~~~~~~~~~~~~~~~~~~~~~
xxx/blender/intern/cycles/blender/display_driver.cpp:719:7: error: value of type 'void' is not contextually convertible to 'bool'
  if (!DCHECK_NOTNULL(texture.gpu_texture)) {
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
xxx/blender/intern/cycles/blender/display_driver.cpp:887:8: error: value of type 'void' is not contextually convertible to 'bool'
  if (!DCHECK_NOTNULL(gpu_upload_sync_) || !DCHECK_NOTNULL(gpu_render_sync_)) {
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
xxx/blender/intern/cycles/util/log.h:57:38: note: expanded from macro 'DCHECK_NOTNULL'
#  define DCHECK_NOTNULL(expression) LOG_SUPPRESS()
                                     ^~~~~~~~~~~~~~
xxx/blender/intern/cycles/util/log.h:35:47: note: expanded from macro 'LOG_SUPPRESS'
#  define LOG_SUPPRESS() (true) ? ((void)0) : LogMessageVoidify() & StubStream()
                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
xxx/blender/intern/cycles/blender/display_driver.cpp:887:41: error: invalid operands to binary expression ('void' and 'bool')
  if (!DCHECK_NOTNULL(gpu_upload_sync_) || !DCHECK_NOTNULL(gpu_render_sync_)) {
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

gcc (10 && 12) I get

xxx/blender/intern/cycles/util/log.h:35:33: error: could not convert '(false ? (void)0 : ccl::LogMessageVoidify().ccl::LogMessageVoidify::operator&(ccl::StubStream()))' from 'void' to 'bool'
   35 | #  define LOG_SUPPRESS() (true) ? ((void)0) : LogMessageVoidify() & StubStream()
xxx/blender/intern/cycles/util/log.h:57:38: note: in expansion of macro 'LOG_SUPPRESS'
   57 | #  define DCHECK_NOTNULL(expression) LOG_SUPPRESS()
      |                                      ^~~~~~~~~~~~
xxx/blender/intern/cycles/blender/display_driver.cpp:562:8: note: in expansion of macro 'DCHECK_NOTNULL'
  562 |   if (!DCHECK_NOTNULL(tile.buffer_object.gpu_pixel_buffer)) {
      |        ^~~~~~~~~~~~~~
xxx/blender/intern/cycles/blender/display_driver.cpp: In member function 'virtual ccl::half4* ccl::BlenderDisplayDriver::map_texture_buffer()':
xxx/blender/intern/cycles/util/log.h:35:33: error: could not convert '(false ? (void)0 : ccl::LogMessageVoidify().ccl::LogMessageVoidify::operator&(ccl::StubStream()))' from 'void' to 'bool'
   35 | #  define LOG_SUPPRESS() (true) ? ((void)0) : LogMessageVoidify() & StubStream()
xxx/blender/intern/cycles/util/log.h:57:38: note: in expansion of macro 'LOG_SUPPRESS'
   57 | #  define DCHECK_NOTNULL(expression) LOG_SUPPRESS()
      |                                      ^~~~~~~~~~~~
xxx/blender/intern/cycles/blender/display_driver.cpp:616:8: note: in expansion of macro 'DCHECK_NOTNULL'
  616 |   if (!DCHECK_NOTNULL(pix_buf)) {
      |        ^~~~~~~~~~~~~~
xxx/blender/intern/cycles/blender/display_driver.cpp: In member function 'virtual void ccl::BlenderDisplayDriver::unmap_texture_buffer()':
xxx/blender/intern/cycles/util/log.h:35:33: error: could not convert '(false ? (void)0 : ccl::LogMessageVoidify().ccl::LogMessageVoidify::operator&(ccl::StubStream()))' from 'void' to 'bool'
   35 | #  define LOG_SUPPRESS() (true) ? ((void)0) : LogMessageVoidify() & StubStream()
xxx/blender/intern/cycles/util/log.h:57:38: note: in expansion of macro 'LOG_SUPPRESS'
   57 | #  define DCHECK_NOTNULL(expression) LOG_SUPPRESS()
      |                                      ^~~~~~~~~~~~
xxx/blender/intern/cycles/blender/display_driver.cpp:630:8: note: in expansion of macro 'DCHECK_NOTNULL'
  630 |   if (!DCHECK_NOTNULL(pix_buf)) {
      |        ^~~~~~~~~~~~~~
xxx/blender/intern/cycles/blender/display_driver.cpp: In function 'void ccl::draw_tile(const ccl::float2&, int, int, const ccl::DrawTile&)':
xxx/blender/intern/cycles/util/log.h:35:33: error: could not convert '(false ? (void)0 : ccl::LogMessageVoidify().ccl::LogMessageVoidify::operator&(ccl::StubStream()))' from 'void' to 'bool'
   35 | #  define LOG_SUPPRESS() (true) ? ((void)0) : LogMessageVoidify() & StubStream()
xxx/blender/intern/cycles/util/log.h:57:38: note: in expansion of macro 'LOG_SUPPRESS'
   57 | #  define DCHECK_NOTNULL(expression) LOG_SUPPRESS()
      |                                      ^~~~~~~~~~~~
xxx/blender/intern/cycles/blender/display_driver.cpp:719:8: note: in expansion of macro 'DCHECK_NOTNULL'
  719 |   if (!DCHECK_NOTNULL(texture.gpu_texture)) {
      |        ^~~~~~~~~~~~~~
xxx/blender/intern/cycles/blender/display_driver.cpp: In member function 'bool ccl::BlenderDisplayDriver::gpu_resources_create()':
xxx/blender/intern/cycles/util/log.h:35:67: error: could not convert 'ccl::LogMessageVoidify().ccl::LogMessageVoidify::operator&(ccl::StubStream())' from 'void' to 'bool'
   35 | #  define LOG_SUPPRESS() (true) ? ((void)0) : LogMessageVoidify() & StubStream()
      |                                               ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
xxx/blender/intern/cycles/util/log.h:57:38: note: in expansion of macro 'LOG_SUPPRESS'
   57 | #  define DCHECK_NOTNULL(expression) LOG_SUPPRESS()
      |                                      ^~~~~~~~~~~~
xxx/blender/intern/cycles/blender/display_driver.cpp:887:8: note: in expansion of macro 'DCHECK_NOTNULL'
  887 |   if (!DCHECK_NOTNULL(gpu_upload_sync_) || !DCHECK_NOTNULL(gpu_render_sync_)) {
      |        ^~~~~~~~~~~~~~

Hi. I am getting the same errors while building latest blender 3.5 with gcc. Older versions builds successfully. The only way I found to get rid of this error, is to enable -DWITH_CYCLES_LOGGING=ON when configuring blender.

This error comes from the DCHECK_NOTNULL macro. This macro along with a variety of other macros in log.h always resolves to ((void)0) and they never do any checking that the names suggest.

log.h should be reviewed and the macros in there should be redefined to represent the functions that the names suggest.

If the intention is only to fill in stubs to allow compiling when logging is disabled, then a more compatible option would be to always equate to true as these would be used in if statements.