« first day (248 days earlier)      last day (2611 days later) » 

8:45 AM
@trilolil literally 5 minutes after googling opencv particle filter: docs.opencv.org/3.0.0/d9/df8/group__tracking.html
you want to create your own Tracker, setting the TrackerSampler::addTrackerSamplerAlgorithm( "PF" );
 
What would be the correct way to use ternary operation with tuples. What I hoped that would have worked is auto [a,b] = (cond) ? std::make_tuple(1,1) : std::make_tuple(2,2); doesn't work. What would be the correct syntax if this kind of initialization is even feasible.
 
this should actually work if you use C++17
but you most likely aren't
just do bool condition = cond; auto a = condition ? 1 : 2; auto b = condition ? 1 : 2;
 
9:05 AM
Too bad. Thanks!
 
nwp
 
9:42 AM
Hi guys
From this code
especially this snippet
template
class VertexT {
    typedef VertexT Vertex;
    typedef HalfEdgeT HalfEdge;
public:
    //all the getters and setters as usual
protected:
private:
    HalfEdge* incidentEdge;
    VertexDataT data;
};
As yoy can see there's a pointer to an HalfEdge data structure
but if you look at
template
class HalfEdgeT {
    typedef VertexT Vertex;
    typedef HalfEdgeT HalfEdge;
    typedef FaceT Face;
public:
    inline void setTwin(HalfEdge* newTwin) {
        this->twin = newTwin;
        newTwin->twin = this;
    };
    inline void setNext(HalfEdge* newNext) {
        this->next = newNext;
        newNext->prev = this;
    };
    inline void setPrev(HalfEdge* newPrev) {
        this->prev = newPrev;
        newPrev->next = this;
    };
    // all the other getters and setters as usual
you can see that each half edge has a pointer to a Vertex
so each vertex can point to an half edge
but many half edges can have as origin the same vertex
now...
for given vertex
I'd like to write an iterator that would allow me to do stuff like
Vertex* v;
//initialization stuff...
Vertex::halfEdgeIterator it;
for(it = v.begin_halfEdge(); it != v.end_halfEdge(); ++it) {
  HalfEdge *he = *it;
  do_something(it);
}
you can go through all the half edges by using combinations of twin->next etc
so the iterator I have in mind should allow me to go through all the halfedges having v as origin
(this iterator is the most basic one I have in mind, I'd like to develop more of such kind of iterators based on some other properties, but starting with this one would be a good start)
 
nwp
are you rubber-ducking or is there a question in there?
 
the question is how can I design the iterator in this specific case
 
you seem to want to iterate over every incident edge for given vertex
 
yes
that's correct
 
well then whatever you're doing ATM you'll need to do in the operator++ and operator*
forward these operations inside the iterator
 
9:53 AM
I've read online
that these iterators
when designed
given the C++ language, should be related to the STL standard
this is why I'm confused, because if it were for me I'd just write an external class as iterator
but apparently the best way is to implement a nested class for the job
 
whether it's nested class or not is irrelevant
 
are sure? because in the stl list, map, set etc
their iterators are all nested classes
 
they're not
 
what they're not?
 
in libstdc++, std::vector<int>::iterator is a typedef to __gxx::__normal_iterator<int*>
 
9:56 AM
ah
 
they are not nested classes
 
so what actually matters
is the interface of the iterator
not the actual implementation
 
6 mins ago, by milleniumbug
http://en.cppreference.com/w/cpp/concept/InputIterator
 
I don't understand how should use that page as reference
does it tell me the condition to implement the iterator?
 
at minimum you need a increment a dereference and an comparison with the end
 
9:58 AM
this is literally the list of requirements you're expected to satisfy in your iterator implementation
 
everything in the expression column must compile and evaluate to the type in the return column
 
do I need to implement the expressions listed in the expression column then?
the operators that allow me to evaluate the expression in such column I mean
 
it's called operator overloading
 
you need to make it work so the expressions there are valid, compile and do what their description is
 
@ratchetfreak I know what operator overload is
I just struggle to understand because there's no code snippet for an interface of an iterator
and just listing all the valid expressions confuse me a little bit
 
10:08 AM
if you dig into the STL headers a bit you will find a few examples
 
but are they complicated to implement
especially in my case
?
 
nwp
@user8469759 the operators themselves no, the logic how to find the correct half edges I'm not so sure
@user8469759 going from the expressions to a list of required operators should be straightforward
 
I'll give it a go then
I'll let you know
 
10:25 AM
out of curiosity why can a call to a new fail?
 
@user8469759 OOM
 
@BartekBanachewicz what?
 
out of memory
 
out of mana
 
in other words new fails when malloc would also fail
or when the constructor throws an exception
 
10:27 AM
@ratchetfreak I was just writing that
since new is malloc+ ctor, either one failing causes the whole to fail
 
and how can I check if that's the problem?
 
@user8469759 catch the exceptions
 
that's the specific code that fails (but it works for some iterations this is why I think it's weird)
inline bool init_ui(uint32_t** x, int num_bits)
{
   int num_chunks;
   if (size_chunk_4byte(num_bits, &num_chunks)) {
      *x = new uint32_t[num_chunks];
      //*x = (uint32_t*) malloc(num_chunks * sizeof(uint32_t));
      return true;
   }
   return false;
}
and the call is something like
(it's like these two consecutive calls)
I've used the gdb to check if maybe the size was to high
it's not
uint32_t *mem;
init_ui(&mem,35);
 
@nwp You got it to work with C++17 compatible compiler right?
 
(the 35 it's an example)
how do I catch the exception?
 
nwp
10:30 AM
@ELEC yes, except C++17 doesn't exist yet, so it is all a bit experimental
 
@user8469759 how about you paste that into google
 
uint32_t doesn't have a constructor so the only possible failure would be the allocation itself
or because size_chunk_4byte returns false
 
10:51 AM
@набиячлэвэли what do you mean with it doesn't have a constructor?
sorry
@ratchetfreak
 
@user8469759 it trivially initializes
 
I don't understand
 
you don't have to run any special code for an int. It's just a few bytes of memory
if you don't value-initialize it, it sits there with unspecified contents
 
but why would it be un-initialized after a new call?
I don't really get it
 
that's what POD types do
it's an optimization
 
10:55 AM
use std::vector
 
@user8469759 because there's nothing done to it by default, plain and simple
@milleniumbug also that
 
wait wait
ok so
this line
*x = new uint32_t[num_chunks];
I can see from gdb that num_chunks = 1
@milleniumbug let me avoid std::vector for this specific bit, I know they're better
but just let me understand why it doesn't work
 
@user8469759 why would we "let you avoid it"
it's a better solution. Use it.
as if C++ wasn't hard enough vOv
 
because I want to understand why it doesn't work
 
11:01 AM
nuke new from orbit
 
well, you should hide it deep in unique, shared, etc. pointers :)
 
6 mins ago, by milleniumbug
use std::vector
 
ok bartek
why do you think I don't want to use vector
 
@user8469759 use it once and you will never look back
 
@user8469759 I don't really care
pretty much all reasons are wrong
 
11:03 AM
you're wrong
 
yet it's you asking for help in an internet chatroom, not me
 
@nwp At this point "doesn't exist" is almost overstating things. C++17 has been approved by the committee, and sent out to the ISO as a whole for approval. In theory it's possible that some country could object to it and demand a change--but it's really quite unlikely (e.g., if it happened, it would be the first time in the history of C++).
 
my question is about a guess of why that it not working, and I don't see a reason why, there's no solution I'm asking for. And the answer to a constrained problem cannot be "just use something else"
 
it's also possible that the actual problem is somewhere else entirely
 
the general answer for using vectors (they're old): we should raise the level of abstraction in 2017, so you don't mess with raw pointers and malloc calls for another 40 years to accomplish a simple task — which is what happening in your case;
besides, C++ provides zero overhead abstraction for these things, so you will never lose speed
 
11:07 AM
and you are trying to focus on the wrong thing which if you just used std::vector you would know that the allocation just works
@login_not_failed you only lose speed while the compiler is removing all the abstraction overhead
 
nwp
@user8469759 Try to constrain it more by providing a minimal example so people can use their own environment for bug hunting. The code snippet alone isn't enough to reproduce the problem.
 
@ratchetfreak you cannot avoid compilation :) use raw ASM if you like raw pain
 
I can't just change that piece with an std::vector because it would screw up all the interface (which has not been written by me)
so I need to be conservative
 
@user8469759 that's what everyone is saying so nothing is changing
 
@login_not_failed but having the compiler remove 1k lines of templated abstraction code is going to take longer than just compiling the equivalent 3 line function
 
nwp
11:13 AM
@JerryCoffin You are probably right. I just noticed how gcc is repeatedly the first compiler to be C++17 feature complete for a couple of months in a row now and I lost track of what is in and out, so I'll wait until it has become an official iso standard before looking at it again.
 
@user8469759 If this is failing, chances are pretty good that you have something else corrupting the heap. You might want to consider using valgrind or clang's memory sanitizer/address sanitizer. There's a good chance the problem is quite distant from where the symptoms become visible.
 
I was thinking about that
since it says "glibc detected ... memory corruption"
the valgrind output is huge
xD
 
@user8469759 I'd use address sanitizer/memory sanitizer (and probably UB Sanitizer as well) first. If you still have problems after cleaning up what they find, then try valgrind.
 
when compiling for debug a lot of STL implementations will insert asserts in vector's access functions to detect out of bounds...
 
how do I use a sanitizer?
is it a compiler option?
 
11:23 AM
@user8469759 std::vector can present itself as a raw memory buffer.
 
using an out parameter to return a raw buffer is as shitty C++ code as I can imagine. Not changing that immediately is not "constrained"; it's plainly sad.
 
@BartekBanachewicz I can think of worse (but yes, it's pretty awful anyway).
 
@user8469759 you brought it on yourself
 
11:52 AM
@ratchetfreak this is simply a price for using high level abstractions; and by similar logic: if you can write 3 lines in C++ without templates, why not use said ASM instead? maybe it's just a "mov eax, eax" at the end? :)
 
@login_not_failed because the compiler is smarter about this than I am and may be able to remove the entire thing
 
@Mgetz and this too! some compiler optimizations make no sense for a programmer at a glance — I wouldn't do most of the stuff that it does for me
 
12:07 PM
@login_not_failed which is why C is still an acceptible target for when you don't want to pay the cost of 5 minutes of abstraction removal
 
@login_not_failed it's not that you couldn't do this, it's just that the compiler can do it faster. It takes the compiler 5 minutes whereas it might take you several days
 
12:44 PM
@ratchetfreak nobody said pure C is not valid anymore :) the choice simply depends on your task
 
@login_not_failed but you kept skipping it in your comment and went straight for assembly
 
nwp
@ratchetfreak I somewhat disagree. There is no reason to prefer C over C++ because you can just choose to do the abstraction removal manually while preserving the option to have the compiler do it for you. Unless of course you are in embedded or something and the tools just don't exist.
 
@nwp C (or a carefully selected subset of C++)
 
1:25 PM
what does it mean when valgrind provide you an info like:
==709==  Uninitialised value was created by a stack allocation
==709==    at 0x567300: _int_malloc
how can I use the info to spot the where the uninitialised value is generated in my code?
 
...that's it? no stack trace?
also: enable warnings in your compiler
 
break into your program and find memory location 0x567300 and put a breakpoint there
 
you may also try to combine valgrind with gdb
 
ok
I'm trying
thx
 
in Lounge<C++>, Mar 22 '16 at 20:12, by milleniumbug
@sehe I run process in valgrind with valgrind --vgdb=yes --vgdb-error=0 ./my_program and then I follow the instructions (as in, running gdb ./my_program and paste in target remote | /usr/lib64/valgrind/../../bin/vgdb --pid=PID)
^ that will make gdb break at the first place valgrind complains
 
1:32 PM
I'm using this line
valgrind --vgdb=yes --vgdb-error=0 --log-file=log2.txt ./my_program
but it says "Bad option ==vgdb=yes" aborting
 
are you seriously passing ==vgdb=yes
 
nono
sorry
its "--" not "=="
 
@ratchetfreak because stating that one shouldn't use C++ for tasks which it is meant for (metaprogramming) — and substituing it entirely by the code that a compiler would produce, is equally ridiculous as using raw assemler from the get-go...
 
double check that it's a -- (double hyphen) and not a == (double equals sign)
 
Your valgrind version may be old, try upgrading
 
1:35 PM
fuck
 
It worked on whatever version of valgrind Fedora 23 has
 
2:34 PM
That would be 3.10.1 I believe
 
 
3 hours later…
5:26 PM
Is there a way to tell where to look for GLIBXX stuff?
I've changed the compilation removing the -static
(so it's dynamic now)
it compiles but when it run it says
 /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found
/usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found
/usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found
the gcc I'm using is not in that directory
I don't have admin permission so I can't update by myself
I've tried by updating the LD_LIBRARY_PATH variable
it doesn't work
 
6:11 PM
88
Q: Multiple glibc libraries on a single host

dogbaneMultiple glibc libraries on a single host My linux (SLES-8) server currently has glibc-2.2.5-235, but I have a program which won't work on this version and requires glibc-2.3.3. Is it possible to have multiple glibcs installed on the same host? This is the error I get when I run my program on ...

Try looking at this
Maybe it'll help
 
6:56 PM
Just started playing with user_literal definitions, there's a json library that lets you declare json = R"{"stuff": "stuff"}"_json;
And I mistakenly wrote string s = R"{"stuff": "stuff"}"_json;
which compiled just fine but gave a very nasty error on runtime
very hard to track down
Why is it that the compiler (LLVM) isn't able to sort this errors in compile time?
 
R"{"stuff": "stuff"}"_json shouldn't compile
it's a raw string literal without a delimiter and parentheses
 
yup my bad, real thing is too long
 
generally C++ errors are bad, and will be bad
concepts could potentially help, but only with things that would use them
 
I'm just wondering what it is about literals with the user defined object suffix, that makes it hard for the compiler to detect.. well not that I know much about compiling c++, just wondering
here's the real thing pastebin.com/dDsmRc1e
 
haven't used that library
so I can't tell what specifically makes the compile errors bad
 
7:02 PM
no no, there are no compile errors
only runtime
 
what lib is that?
 
ofJson is just using ofJson = nlohmann::json;
 
@SergioBasurco nlohmann::json seems to have a conversion operator
and it fails since that's not a string, but an object
I think that's a questionable design choice
 
I finally got to that, but it failed in runtime, not in compile time
 
well, yeah
 
7:15 PM
I guess... that's what user_literals are there for though, right?
that's odd to me, I'd never found a typechecking error in c++ like that, in runtime
autos and what-have-you all crash during build
dunno
 
tbh, user literal actually could type check that, by parsing at compile time
but this lib doesn't do it
also such compile-time parsing would be sooo annoying to program
there's not much difference here between nlohmann::json("your_json_string") and "your_json_string"_json
 
yup, I was just excited to use user_literals, new to me
thanks
 
@SergioBasurco Use cereal
 
gotta go, i'll check/eat cereal later
 
 
1 hour later…
8:52 PM
Hello, I have a simple question: what can produce a memory corruption of an array in C++ ?
 
1 message moved from Lounge<C++>
 
:36155770 your code
 
@GabrielDevillers undefined behaviour
1 message moved from Lounge<C++>
 
nwp
that is a picture, not an example
 
8:54 PM
an image instead of text... not enough indirection, you could as well print it out, scan it and post it
 
Yes it's true. I'm gonna fire valgrind then
 
yes, that's your best option
in Lounge<C++>, Mar 22 '16 at 20:12, by milleniumbug
@sehe I run process in valgrind with valgrind --vgdb=yes --vgdb-error=0 ./my_program and then I follow the instructions (as in, running gdb ./my_program and paste in target remote | /usr/lib64/valgrind/../../bin/vgdb --pid=PID)
@GabrielDevillers here's what you can try: combining gdb with valgrind
 
@milleniumbug ok thanks for the suggestion
 
@GabrielDevillers Another suggestion is make sure you don't have any warning. For example, if you have a function that should return a value, but doesn't, this will fuck the stack.
 
Nov 29 '16 at 17:38, by milleniumbug
PSA: Enable warnings in your compiler if you haven't already (in gcc: -Wall -Wextra -pedantic)
 
8:59 PM
@GabrielDevillers Another suggestion is to run static code analysis, so that if you have typos, etc, it shows up as a "grammar" error in the IDE.
 
Thanks for these advices
 
 
3 hours later…
11:50 PM
Found my bug. I was creating a dangling reference to my array...
 

« first day (248 days earlier)      last day (2611 days later) »