I asked an earlier question that came out of topic in CString and Unicode.
Now I have reduced my example to namespace std and cout (instead of printf ).
But the main problem still remains.
This is related, but separately from the question, nominated as a duplicate . This question concerns cards in cards and older than 2 years, given that the problem is a priority for the compiler team. (Clearly, this is not a priority)
This question is worth staying open.
Am I using initializers correctly?
Is there an easy way to fix this without a major workaround?
(This is a minimal example based on a much more complex program)
#include <map> #include <string> #include <iostream> struct Params { int inputType; std::string moduleName; }; int main() { std::map<std::string, Params> options{ { "Add", { 30, "RecordLib" } }, { "Open", { 40, "ViewLib" } }, { "Close", { 50, "EditLib" } }, { "Inventory", { 60, "ControlLib"} }, { "Report", { 70, "ReportLib" } } }; for (const auto& pair : options) { std::cout << "Entry: " << pair.first << " ==> { " << pair.second.moduleName << " }" << std::endl; } return 0; }
Exit
Entry: ==> { } Entry: Report ==> { }
You can see only the final line "Report" .
It really seems to me that the intializer list for std::map just broken.
I am using Microsoft Visual Studio 2013 with Unicode.
This happens on both Debug and Release lines, with Optimizations Disabled or /O2 The same code works fine on IDEOne
c ++ c ++ 11 visual-studio visual-studio-2013
abelenky
source share