Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-6305

UNINIT_VAR emits code in non-debug builds

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 5.5.37, 10.0.11, 10.1.0
    • Fix Version/s: 10.1.1
    • Component/s: None
    • Labels:
      None

      Description

      Leaving variables uninitialized in certain cases helps to achieve top-notch performance. Sometimes compiler thinks that variable may be used uninitialized (whereas it may not) and emits a warning.

      To silence these warnings there is UNINIT_VAR() macro:

      #if defined(_lint) || defined(FORCE_INIT_OF_VARS) || \
          defined(__cplusplus) || !defined(__GNUC__)
      #define UNINIT_VAR(x) x= 0
      #else
      /* GCC specific self-initialization which inhibits the warning. */
      #define UNINIT_VAR(x) x= x
      #endif

      There are a few problems with this macro:
      1. It always emits "x= 0" for non-gcc
      2. It always emits "x= 0" for C++ code

      It means leaving variable uninitialized makes sense only in C code compiled by gcc.

      Regarding __cplusplus: there is a reference to gcc bug which was fixed 3 years ago. Probably it is time to remove it?

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              svoj Sergey Vojtovich
              Reporter:
              svoj Sergey Vojtovich
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: