Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-9637

WiredTiger strict compilation failure with gcc-11 on ubuntu 22.04

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 6.1.0-rc0, WT11.1.0, 6.0.4
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Storage Engines
    • 1
    • Storage Engines - 2022-08-08
    • v6.0

      Compiling WiredTiger with strict mode leads to the following error:

      In file included from /home/hari/work/code/wiredtiger/src/include/wt_internal.h:402,
                       from /home/hari/work/code/wiredtiger/src/reconcile/rec_write.c:9:
      /home/hari/work/code/wiredtiger/src/reconcile/rec_write.c: In function '__wt_reconcile':
      /home/hari/work/code/wiredtiger/src/include/hardware.h:51:72: error: unsigned conversion from 'int' to 'uint16_t' {aka 'short unsigned int'} changes the value of '-3' [-Werror=sign-conversion]
         51 |         } while (!__wt_atomic_cas16(&(p)->flags_atomic, __orig, __orig & ~((uint16_t)(mask)))); \
            |                                                                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
      /home/hari/work/code/wiredtiger/src/reconcile/rec_write.c:101:5: note: in expansion of macro 'F_CLR_ATOMIC_16'
        101 |     F_CLR_ATOMIC_16(ref->page, WT_PAGE_COMPACTION_WRITE);
            |     ^~~~~~~~~~~~~~~
      

      Changing it according to the following code fixed the issue.

               do {                                                                                  \
                   __orig = (p)->flags_atomic;                                                       \
      -        } while (!__wt_atomic_cas16(&(p)->flags_atomic, __orig, __orig & ~(uint16_t)(mask))); \
      +        } while (!__wt_atomic_cas16(&(p)->flags_atomic, __orig, __orig & (uint16_t)(~(mask)))); \
           } while (0)
      

            Assignee:
            haribabu.kommi@mongodb.com Haribabu Kommi
            Reporter:
            haribabu.kommi@mongodb.com Haribabu Kommi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: