1

I have declared a vector container like this

const  std::vector<std::uint8_t> Levels = {0x01U, 0x02U, 0x07U, 0x11U};

The clang gives me these warnings,

test.cpp:6:1: warning: static objects are disallowed; if possible, use a constexpr constructor instead [fuchsia-statically-constructed-objects]
const  std::vector<std::uint8_t> Levels = {0x01U, 0x02U, 0x07U, 0x11U};
^
test.cpp:6:34: warning: initialization of 'Levels' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp]
const  std::vector<std::uint8_t> Levels = {0x01U, 0x02U, 0x07U, 0x11U};
                                 ^
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_vector.h:622:7: note: possibly throwing constructor declared here
      vector(initializer_list<value_type> __l,
      ^
test.cpp:6:43: warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]
const  std::vector<std::uint8_t> Levels = {0x01U, 0x02U, 0x07U, 0x11U};
                                          ^
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_vector.h:623:7: note: default parameter was declared here
             const allocator_type& __a = allocator_type())
             ^

Whats the proper solution to fix this?

ganeshredcobra
  • 1,881
  • 3
  • 28
  • 44

0 Answers0