Compiling the following code with MSVC 19.11 leads to the conclusion
With 32: 0 99 2 With 64: 0 1 2
with a 32-bit compiler and
With 32: 0 1 2 With 64: 0 99 2
with a 64-bit compiler.
The problem is that the list of initializers for individual elements is of type size_t
. Is this a compiler error (until I found it still not reported anywhere), and not the case where the standard is ambiguous (neither clang nor gcc have this problem)?
#include <cstdint>
#include <vector>
#include <iostream>
int main() {
using T = std::uint16_t;
{
std::vector<T> s0;
std::vector<T> s1( { 99u } );
std::vector<T> s2( { 40u, 70u } );
std::cout << "With " << sizeof(0u)*8 << ':' << ' '
<< s0.size() << ' ' << s1.size() << ' ' << s2.size() << '\n';
}
{
std::vector<T> s0;
std::vector<T> s1( { 99ull } );
std::vector<T> s2( { 40ull, 70ull } );
std::cout << "With " << sizeof(0ull)*8 << ':' << ' '
<< s0.size() << ' ' << s1.size() << ' ' << s2.size() << '\n';
}
return 0;
}
Command and compiler (s):
cl.exe ilist.cpp & .\ilist.exe
cl.exe
Microsoft (R) C/C++ Optimizing Compiler Version 19.11.25507.1 for x64
Copyright (C) Microsoft Corporation. All rights reserved. (or x86)
x64\cl.exe and x86\cl.exe from
...\Tools\MSVC\14.11.25503\bin\HostX64\
source
share