Examples of errors detected by the V616 diagnostic.

V616. The 'Foo' named constant with the value of 0 is used in the bitwise operation.


Mozilla Firefox

V616 The 'eBorderStyle_none' named constant with the value of 0 is used in the bitwise operation. nswindow.cpp 2278


enum nsBorderStyle {
  eBorderStyle_none = 0,
  ....
};

NS_IMETHODIMP
nsWindow::SetNonClientMargins(nsIntMargin &margins)
{
  if (!mIsTopWidgetWindow ||
      mBorderStyle & eBorderStyle_none ||
      mHideChrome)
    return NS_ERROR_INVALID_ARG;
  ....
}

Most likely this is what should be written here: mBorderStyle != eBorderStyle_none


LibreOffice

V616 The 'WW8_TOP' named constant with the value of 0 is used in the bitwise operation. ww8par6.cxx 4742


enum BRC_Sides
{
    WW8_TOP = 0, WW8_LEFT = 1, WW8_BOT = 2,
    WW8_RIGHT = 3, WW8_BETW = 4
};

void SwWW8ImplReader::Read_Border(....)
{
  ....
  if ((nBorder & WW8_LEFT)==WW8_LEFT)
    aBox.SetDistance(
      (sal_uInt16)aInnerDist.Left(), BOX_LINE_LEFT );

  if ((nBorder & WW8_TOP)==WW8_TOP)
    aBox.SetDistance(
      (sal_uInt16)aInnerDist.Top(), BOX_LINE_TOP );

  if ((nBorder & WW8_RIGHT)==WW8_RIGHT)
    aBox.SetDistance(
      (sal_uInt16)aInnerDist.Right(), BOX_LINE_RIGHT );

  if ((nBorder & WW8_BOT)==WW8_BOT)
    aBox.SetDistance(
      (sal_uInt16)aInnerDist.Bottom(), BOX_LINE_BOTTOM );
  ....
}

Unreal Engine 4

V616 The 'SolidMesh' named constant with the value of 0 is used in the bitwise operation. debugrendersceneproxy.cpp 156


enum EDrawType
  {
    SolidMesh = 0,
    WireMesh = 1,
    SolidAndWireMeshes = 2,
  };

void FDebugRenderSceneProxy::GetDynamicMeshElements(....) const
{
  ....
  if (DrawType & SolidAndWireMeshes || DrawType & SolidMesh)
  {
    GetCylinderMesh(....);
  }
  ....
}

Identical errors can be found in some other places:

  • V616 The 'SolidMesh' named constant with the value of 0 is used in the bitwise operation. debugrendersceneproxy.cpp 169
  • V616 The 'SolidMesh' named constant with the value of 0 is used in the bitwise operation. debugrendersceneproxy.cpp 183
  • V616 The 'SolidMesh' named constant with the value of 0 is used in the bitwise operation. debugrendersceneproxy.cpp 197
  • And 1 additional diagnostic messages.

Unreal Engine 4

V616 The 'DT_POLYTYPE_GROUND' named constant with the value of 0 is used in the bitwise operation. pimplrecastnavmesh.cpp 2006


enum dtPolyTypes
{
  DT_POLYTYPE_GROUND = 0,
  DT_POLYTYPE_OFFMESH_POINT = 1,
  DT_POLYTYPE_OFFMESH_SEGMENT = 2,
};

uint8 GetValidEnds(...., const dtPoly& Poly)
{
  ....
  if ((Poly.getType() & DT_POLYTYPE_GROUND) != 0)
  {
    return false;
  }
  ....
}

Mozilla Thunderbird

V616 The 'eBorderStyle_none' named constant with the value of 0 is used in the bitwise operation. nswindow.cpp 2318


enum nsBorderStyle
{
  eBorderStyle_none = 0,
  ....
}

NS_IMETHODIMP nsWindow::SetNonClientMargins(....)
{
  if (!mIsTopWidgetWindow ||
      mBorderStyle & eBorderStyle_none)
    return NS_ERROR_INVALID_ARG;
  ....
}

Identical errors can be found in some other places:

  • V616 The 'nsIDocShell::BUSY_FLAGS_NONE' named constant with the value of 0 is used in the bitwise operation. presentationcallbacks.cpp 105

ReactOS

V616 The '(mdtModule)' named constant with the value of 0 is used in the bitwise operation. assembly.c 156


typedef enum CorTokenType
{
    mdtModule         = 0x00000000,
    mdtTypeRef        = 0x01000000,
    ....
    mdtModuleRef     = 0x1a000000,
    mdtTypeSpec      = 0x1b000000,
    mdtAssembly      = 0x20000000,
    mdtAssemblyRef = 0x23000000,
    ....
} CorTokenType;

#define TypeFromToken(tk) ((ULONG32)((tk) & 0xff000000))
#define TableFromToken(tk) (TypeFromToken(tk) >> 24)

static inline ULONG get_table_size(....)
{
  INT tables;
  ....
  tables = max(
    assembly->tables[TableFromToken(mdtModule)].rows, // <=
    assembly->tables[TableFromToken(mdtModuleRef)].rows);
  ....
}

Clang

V616 The 'SymbolRef::ST_Unknown' named constant with the value of 0 is used in the bitwise operation. MachODebugMapParser.cpp 448


enum Type {
  ST_Unknown, // Type not specified
  ST_Data,
  ST_Debug,
  ST_File,
  ST_Function,
  ST_Other
};

void MachODebugMapParser::loadMainBinarySymbols(....)
{
  ....
  SymbolRef::Type Type = *TypeOrErr;
  if ((Type & SymbolRef::ST_Debug) ||
      (Type & SymbolRef::ST_Unknown))
    continue;
  ....
}

Most likely this is what should be written here: if ((Type == SymbolRef::ST_Debug) || (Type == SymbolRef::ST_Unknown))


CMaNGOS

V616 The 'SPELL_DAMAGE_CLASS_NONE' named constant with the value of 0 is used in the bitwise operation. Spell.cpp 674


enum SpellDmgClass
{
  SPELL_DAMAGE_CLASS_NONE     = 0,                       // <=
  SPELL_DAMAGE_CLASS_MAGIC    = 1,
  SPELL_DAMAGE_CLASS_MELEE    = 2,
  SPELL_DAMAGE_CLASS_RANGED   = 3
};

void Spell::prepareDataForTriggerSystem()
{
  ....
  if (IsPositiveSpell(m_spellInfo->Id))
  {
    if (m_spellInfo->DmgClass & SPELL_DAMAGE_CLASS_NONE) // <=
    {
      m_procAttacker = PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_POS;
      m_procVictim = PROC_FLAG_TAKEN_SPELL_NONE_DMG_CLASS_POS;
    }
  }
  ....
}

Identical errors can be found in some other places:

  • V616 The 'SPELL_DAMAGE_CLASS_NONE' named constant with the value of 0 is used in the bitwise operation. Spell.cpp 692


Do you make errors in the code?

Check your code
with PVS-Studio

Static code analysis
for C, C++ and C#

goto PVS-Studio;