Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-14767

Detect integer conversion loss

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Incomplete
    • Major
    • None
    • 3.0.1
    • build
    • Security Level: Public
    • None

    Description

      in
      https://issues.couchbase.com/browse/MB-14496

      it was discovered that integer conversion loss produces no warnings.

      [root@rualpe-vm2 ~]# cat tt.C
      #include <inttypes.h>
       
      uint64_t vers = 0x10000;
      uint16_t lala = vers;
      [root@rualpe-vm2 ~]# g++   -Werror -Wall -Wextra -pedantic -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wundef -Wno-unused -Wno-variadic-macros -Wno-parentheses -fdiagnostics-show-option -c -o tt.o tt.C
      [root@rualpe-vm2 ~]#
      

      It is important to figure out proper mechanism to detect this.

      • gcc option? (could not find yet)
      • some static analysis?

      God knows how many bugs like
      https://issues.couchbase.com/browse/MB-14496
      this may lurk in code

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              ceej Chris Hillery
              paf Alexander Petrossian (PAF)
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty