Archived

This topic is now archived and is closed to further replies.

carb

std::vector Problem

Recommended Posts

For some reason, when I create three vectors of type std::vector ... Only the first work. Trying push_back on the second and third declared vectors turns into a segmentation fault. The actual declaration is: std::vector list1, list2, list3; list1.push_back(5) // is fine list2.push_back(6) // seg fault same if i try pushing list2 before list1, it seg faults on list2 ... What''s the dilio? - Ben

Share this post


Link to post
Share on other sites
I just tried it, and it works fine. no faults or anything.

maybe your OS has mangled memory up together that dont belong to eachother. Maybe try restarting your computer? Alternatively, reinstall format/reinstall everything.


:::: [ Triple Buffer ] ::::

Share this post


Link to post
Share on other sites
not sure if you need to reformat and stuff, that sounds kinda harsh. But could you repost your code? Preferably in [ source ] tags? Since we can''t see what type you''re creating your vector with. If it''s some built in type (like int, float, etc) then there should be no problem with your code. If it''s some class that you did then mabye somethings wrong with your constructor?

}-- Programmer/Gamer/Dreamer --{

Share this post


Link to post
Share on other sites
He''s using unsigned ints (click ''edit'').

I see no reason why it should segfault.


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]

Share this post


Link to post
Share on other sites
quote:
Original post by Seriema
not sure if you need to reformat and stuff, that sounds kinda harsh. But could you repost your code? Preferably in [ source ] tags? Since we can''t see what type you''re creating your vector with. If it''s some built in type (like int, float, etc) then there should be no problem with your code. If it''s some class that you did then mabye somethings wrong with your constructor?

}-- Programmer/Gamer/Dreamer --{


It looks like he''s using ints. But you''re right, if its a custom type then maybe that is where the problem is...

carb: either use source tags especially for templates or type the actual html codes ie: "& g t ;" for the greater then sign (without spaces) or "& l t ;" for less then

vector<int>


:::: [ Triple Buffer ] ::::

Share this post


Link to post
Share on other sites
quote:
Original post by Fruny
He''s using unsigned ints (click ''edit'').

I see no reason why it should segfault.


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]




hmm. indeed. BTW Fruny, you know that whoever tries to search for answers to boost questions in these forums gets all the posts you ever made on gamedev with that sig of yours. Its impossible really. Ive recentrly been a victim :/


:::: [ Triple Buffer ] ::::

Share this post


Link to post
Share on other sites