Re: g++ 4.8.2: help on vector

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10 June 2014 07:07, Francis ANDRE wrote:
>     vector<int*>    v(5);
>     v.push_back(&i);
>     v.push_back(&j);
>     v.push_back(&k);

The program behaves as required by the standard.

I'm not sure what you expected, are we supposed to guess what you
think the correct output is?

Maybe you wanted to write this instead:

vector<int*> v;
v.reserve(5);
v.push_back(&i);
v.push_back(&j);
v.push_back(&k);

Or simply:

vector<int*> v;
v.push_back(&i);
v.push_back(&j);
v.push_back(&k);


> Is this could be a bug?

Thousands and thousands of experienced C++ developers use GCC's
std::vector every day. It's usually wiser to assume you've
misunderstood than to assume you've found a bug with such a simple
piece of code.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux