Conversion to std::array<unsigned char, 1ul>::value_type from int may alter its value

Viewed 1355

The -Wconversion GCC parameter produces the warning from the title when compiling this program:

#include <iostream>
#include <array>
#include <string>

int main ()
{
    std::string test = "1";
    std::array<unsigned char, 1> byteArray;

    byteArray[0] = byteArray[0] | test[0];

    return 0;
}

Here is how I compile it: g++- -Wall -Wextra -Wconversion -pedantic -std=c++0x test.cpp and I'm using GCC 4.5.

Am I doing something illegal here? Can it cause problems in certain scenarios? Why would the | produce an int?

3 Answers
Related