Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Lensflare17475316d@AlgoRythm oh you remind me of yet another reason to never touch C++ again.
Too many traps. -
Hazarth9521316djust checking that you're using valgrind to investigate this and will never ever stop using it in the future
-
LotsOfCaffeine4281316dthe worst part about this is that the compiler won't give a shit about it, even if it can directly detect this.
Edit: clang-tidy has a warning for that, might be interesting (https://clang.llvm.org/extra/...) -
AlgoRythm50254316d@Hazarth I’m using smart pointers, lots of shared ownership too, will it work well in this case?
-
thebiochemic3012316d@Hazarth valgrind is super useful in general 👌
but definitely a must have for C++ -
Hazarth9521315d@AlgoRythm chances are it will at least notice something is wrong and warn you, giving you a rough idea where it happens. Even if smart pointers can be a bit harder to trace, valgrind has ways to help you. For example the heap profiler might come in handy to see which objects are being allocated a lot. It's one of the best tools for a c++ dev, hands down
-
AlgoRythm50254315d@Hazarth Yeah, I used the visual studio heap profiler and it's a really good diagnostic tool
-
shovethisrant5987315dOur prof used to beat us if we were caught with any memory leaks in our code
-
lorentz15183314dC++ allows you to customize your classes by picking individual answers to questions like:
- do you want polymorphism?
- should polymorphism actually work?
- should the subclasses leak? -
LotsOfCaffeine4281314d@lorentz oh I have a good one too: do you want schroedingers polymorphism? Then just implement the public virtual functions as private and see what happens!
-
lorentz15183314d@LotsOfCaffeine I can't fathom why this is legal. It has literally no legitimate use cases.
-
AlgoRythm50254313d@lorentz Well maybe the derived class is more modest than it's predecessors?? It won't just open up its virtual functions for any old object that asks?
-
LotsOfCaffeine4281307d
-
AlgoRythm50254307d@LotsOfCaffeine just added __PRETTY_FUNCTION__ to my list of things I know. Looks like it might me a gcc-only extension though.
Edit: in visual c++ __FUNCSIG__ -
LotsOfCaffeine4281307d@AlgoRythm yeah its gnu specific, though I think clang has something with a similar name
__FUNCTION__ is standard, though I think it stems from C and is only the functions name, not the return type, class, namespace, template arguments, etc
Related Rants
-
xjose97x19Just saw a variable in C named like this: long time_ago; //in a galaxy far away I laughed no stop.
-
Unskipp24So this happened last night... Gf: my favorite bra is not fitting me anymore Me: get a new one ? Gf: but it ...
-
sam966911Hats off to this lady .... I would have just flipped the machine
Lesson learned: if you're going to derive a class in c++, make sure to declare a virtual destructor on the base class!
I just fixed (one of...) the massive memory leaks in my damn project.
Pictured: the strings in a derived class actually getting freed!
rant
c++