Skip to content

[Feature Request]: Issues found PVS studio static analyzer: liverpool_to_vk.cpp #4922

Description

@Seraphimt

Checklist

  • I have searched for a similar issue in this repository and did not find one.

Description

Analyzer message:
V634 The priority of the * operation is higher than that of the << operation. It`s possible that parentheses should be used in the expression. liverpool_to_vk.cpp 759

Suspicious expression and it's easy to break something due to operator precedence. Requires a comment\simplification.

// Table 8.13 Data and Image Formats [Sea Islands Series Instruction Set Architecture]
static const size_t amd_gpu_data_format_bit_size = 6;   // All values are under 64
static const size_t amd_gpu_number_format_bit_size = 4; // All values are under 16

static auto surface_format_table = []() constexpr {
  std::array<vk::Format, 1 << amd_gpu_data_format_bit_size * 1 << amd_gpu_number_format_bit_size>
    result;
  for (auto& entry : result) {
    entry = vk::Format::eUndefined;
  }
  for (const auto& supported_format : SurfaceFormats()) {
    result[GetSurfaceFormatTableIndex(supported_format.data_format,
                                      supported_format.number_format)] =
        supported_format.vk_format;
  }
  return result;
}();

Link to an article with additional information: https://pvs-studio.com/en/blog/posts/cpp/1405/

Reason

Fixing potential bug and\or code quality.

Examples

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions