On 4/30/2021 6:22 PM, Sam wrote:
> #include <vector>
> #include <memory>
>
> static char UTC[4];
>
> void func(std::vector<char> &vec)
> {
> vec.clear();
> vec.insert(vec.end(), UTC, UTC+4);
> }
Checked this on GodBolt, x86-64 gcc 11.1:
_________________
#include <vector>
#include <iostream>
static char UTC[4];
std::vector<char>::size_type
func(std::vector<char> &vec)
{
vec.clear();
vec.insert(vec.end(), UTC, UTC+4);
return vec.size();
}
int main()
{
std::vector<char> vec;
std::vector<char>::size_type n = func(vec);
std::cout << "n = " << n << "\n";
return 0;
}
_________________
I get the following output with -Wall and -pedantic:
_________________
#1 with x86-64 gcc 11.1
ASM generation compiler returned: 0
Execution build compiler returned: 0
Program returned: 0
n = 4
_________________
Not sure what is wrong with 11.0.1.