VS2013: Initializer list crashes



  • Hi,

    The following code works here, but crashes in Visual Studio 2013 Preview both in Debug and Release modes (default C++ settings, empty project):

    #include<string>
    #include<vector>
    using namespace std;
    int t(vector<string>const&,vector<string>const&v){return v[0][0];}
    int main(){t({""},{"#"}); return 0;}
    

    Is the code correct or I am doing something wrong?


  • Mod

    Converting "\0" to std::string generates an empty string. Accessing its first element then should be undefined.



  • Thanks camper, but this was not the relevant issue. I have corrected the post.

    Should I submit the bug to Microsoft?



  • SAn schrieb:

    Should I submit the bug to Microsoft?

    Yes, of course.





  • How do you know the initializer_list is the bug source? I'm pretty sure you reported this specific case on purpose, but i don't think that it's essential to provide an unnecessary parameter or the like. I somehow can't believe you really simplified this problem to the root (the code just looks sort of special).

    Can you reproduce the same behavior...

    • ... without the unnecessary parameter?
    • ... also when creating a temporary explicitly (or some prvalue-vector, initialized with an initializer-list respectively) and passing it to the function?

    my fault

    It only is your "fault" if you write code which, by the standard, results in undefined behavior. Everything else* is legal code and should at least run just fine. Unfortunately, VC++ has quite a lot of bugs, so...

    ~*By which i do not include ill-formed code ;)~



  • Can you reproduce the same behavior without the unnecessary parameter?
    No. I really cannot simplify the code further.

    Can you reproduce the same behavior when creating a temporary explicitly (or some prvalue-vector, initialized with an initializer-list respectively) and passing it to the function?
    No.

    Unfortunately, VC++ has quite a lot of bugs, so...
    You see, when there is a contradiction between some standard and Microsoft software, then probably the standard is wrong...



  • SAn schrieb:

    You see, when there is a contradiction between some standard and Microsoft software, then probably the standard is wrong...

    😃 for sure the c++ standard isnt without mistakes. nothing is without mistakes is it. but id kinda blame the MSVC rather blaming the standard, definitely. MSVC sometimes does strange things like binding temporaries to non-const-ref. for that reason alone id blame MSCV for ever and ever. 😃 yet i dont wanna miss my visual studio. 🙂



  • Thay say this one is already fixed.


Log in to reply