> Obviously I am doing something wrong when setting o4 but it would be nice if 
> I could get a compile error... 

Hi Henry,

Yes, this recently confused me as well, and here is what I found:

The issue is that QStringList("g","goessouth") behaves the same way as 
std::vector<QString>(“g","goessouth"). In both cases, the string literals 
collapse to pointers, and we call the QStringList(InputIt first, InputIt last) 
overload. The result will likely be a buffer overrun and possibly a crash. If 
you use the curly braces to initialize with an initializer list, the code does 
what you expect.

I agree that it would be nice to have a compiler error but given that 
QStringList behaves the same way as std::vector, I am not sure it is a bug.

Best regards,
Jøger
-- 
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development

Reply via email to