« first day (2132 days earlier)      last day (2833 days later) » 
00:00 - 19:0019:00 - 00:00

7:14 PM
Has anybody gotten messed up by std::vector's over-allocation. I got to "arena allocate" a systems worth of memory, and was thinking of either std::vector or a unique_pointer. Vector has nice bounds checking, but I'm afraid the overallocation might try to allocate more ram then the system has. The unique pointer would involve an extra include which makes me sad.
 
nwp
@Mikhail use vector + reserve to get the amount you want to allocate
besides that vector and unique_ptr do completely different things and an extra include should really not matter in that choice
 
@nwp @Mikhail you can even pre-construct the vector with the number of elements you need and over-write their values. If you know the number of values at compile-time, I suggest std::array
 
I think .reserve() will over allocate?
From what I recall, std::vectors tend to allocate in implementation specific increments...
 
@Mikhail It's currently allowed to overallocate, but IIRC no implementation currently does that.
 
There's a proposal to have reserve forward directly to the allocator and not handle overallocation by itself.
 
7:24 PM
There was even a paper saying "let's require that after reserve(n), capacity() == n", which was rejected on the grounds of (1) this is overconstraining and (2) already a common practice.
@Morwenn Are you talking about the one that was rejected in Oulu?
 
Yup.
Maybe I got it wrong.
 
@JonathanWakely is going to write a paper that'll do something saner.
Not sure if that pings when someone's been away for a long time.
 
Okay, fuck I'll blame you guys if I run out of memory :-)
 
lol
 
@Griwes Ooooh, right, it was that one :o
@Mikhail No chance, you won't remember.
9
 
7:27 PM
> Carruth says the flexibility is important. Wakely responded that he intends to add a feature ASAP which will allow vectors and allocators to coordinate when they want to do something different, and that can be an opt-in which would then remove this guarantee for allocators providing the new feature. Carruth wants this to wait until the new feature is present, so that std::allocator can use the new feature.
> Van Eerd said having two functions, one to do this and one to possibly overallocate, would be nice.
Oh, this is a fun one:
> Tong says that he has an implementation which does try to allocate additional memory, and if that fails it catches the bad_alloc and retries the exact quantity.
:D
Two last comments from minutes:
> Smith says that even with this guarantee the vector might have to allocate extra memory for its own data member, so there's no guarantee this change ensures exactly the requested size anyway.
So you're screwed anyway...
> Wakely says it works today with all implementations, so no rush to fix it.
So blame @JonathanWakely if you run out of memory. :D
 
@Griwes Catching std::bad_alloc o__o
 
@Morwenn ...that was the general reaction at the plenary, yes.
:D
 
Still the exception is right next to the core language.
 
@Mikhail A hacky work-around is to put your own allocator into std::vector. Then you can fail the allocation whenever you want.
 
8:01 PM
@Griwes I've seen a few pieces of software that do that (catch bad_alloc and try same exact allocation again). Can't imagine where that did something.
 
user1804599
ugh
 
user1804599
it's 2016 why does the standard library not have an endian conversion function for every integral type
 
Which programming language?
 
user1804599
C, C++
 
What, didn't you stop those? :v
 
8:08 PM
@Borgleader
-13
Q: HOW TO PLAY NUM OF TIME MUSIC <NO TIME LIMIT> IN ANDROID .... HELP ME

rohith hackthon@Override public void onClick(View v) { if (!flag) { button3.setBackgroundResource(R.drawable.ic_pause); mySound1.setLooping(true); mySound1.start(); flag = true; } else { ...

-14
Q: Need directions (help)

DunnosI am 17 years old in 11grade, currently coding in c++ language. I know Variable types, if conditions, while and for loops, functions, data structures. I can code programs that are in IT state exams. I know that its not a lot for a 17 year old :(, but i want to progress and move forward so I am as...

 
Mystical, the deep sea explorer.
(the typo was intentional)
 
user1804599
@Morwenn the thing I'm writing is best written in C, because C, C++ and Haskell are the only languages with a decent ØMQ library, C++ tooling sucks diseased donkey ballsack, and Haskell is a pain to link to from anything else
 
Oh.
 
user1804599
Plus, isn't it beautifru!
 
user1804599
static void write_string(char *buf, size_t *bufp, edx_string value) {
    write_uint16(buf, bufp, value.length);
    memcpy(buf + *bufp, value.utf8, value.length);
    *bufp += value.length;
}
 
8:15 PM
@Mysticial fucking hell
but i'm almost the same age...
 
nwp
@rightfold y u no std::experimental::string_view?
 
he's got a -1 for every year of life
 
user1804599
cuz C
 
nwp
oh
 
user1804599
8:18 PM
 
nwp
unzigned?
 
user1804599
Yeah because unsigned is a keyword!
 
nwp
go with unsigned with a 0-width space in it
 
@rightfold You're only saying that because you got to use memcpy :p
 
user1804599
syntax error
 
@Mysticial Why do so many noobs yell in their titles sigh
 
-2
Q: Does std::tuple accept auto as a type

FallingFromBedI have to return an int and a function object to the caller, I was thought of returning a tuple like make_tuple(int,[](some){}) I am now on GCC that doesn't support decltpe(auto) as a return type, is ther any way i could make my return type as std::tuple<int,auto> myfun() right now I've been doin...

@NathanOliver I am not sure , i wanna make it sure before i compile, the compilation takes hell time, i don't wanna stuck in that — FallingFromBed 59 mins ago
 
nice one, on account of OP not testing his code due to compile times.
 
9:09 PM
@Mikhail He clearly needs to learn about coliru
 
@Mikhail btw, you were asking yesterday, I would say industry has been more fun than research for me, but not by much.
 
@ChemiCalChems Not enough templates to have the right to complain about compile time.
 
@Mysticial true
 
> Every month this year has been the hottest on record
> “The streak of consecutive records started in May 2015,” Sanchez-Lugo told me. We’ve now lapped ourselves, and are starting to break records set within this same streak, last year.
 
Just to clarify. By "hottest on record" they mean hottest month for that particular month right? As in January 2016 was the hottest January ever on record?
Because I don't see how January 2016 can be hotter than May 2015 unless you're in the southern hemisphere.
 
9:39 PM
When you want to sleep but the manga is simply too cute.
 
@Mysticial I would hope so :P
 
@Mysticial Since 1880 motherboard.vice.com/read/…
 
9:54 PM
@Morwenn What manga?
 
@ThePhD Girl Friends, a shôjo-ai from a decade ago (already ç____ç).
 
@sehe dat link... "motherboard". For a sec there, you got me excited until I realized that it's about how fucked we are.
 
It seems like a good site. Only discovered it a week ago
 
nwp
g++ -O0 -ggdb -fno-omit-frame-pointer and still some of the symbols are inaccessible in gdb -.-
 
Is it UB to call an object's destructor from a method? Or is it only UB when you try to access any of the object's fields/methods after the destructor returns?
 
nwp
10:05 PM
delete this; is not necessarily UB, so I would not expect calling the destructor to be UB either
but the same caveats apply
 
Ok. So the standard doesn't flat out ban it. Technically it will work. Just wondering if the standard says anything about it.
 
nwp
and by same caveats I mean the exact opposite, so instead of "must have been allocated by new, not by placement new" I mean "must have been allocated by placement new, not by new"
 
Roll the destructor into a separate function, and call that. Then you can implement the so called "zombie" object paradigm where every member has an if(isalive) check. This is how file handles are freed in Java - if at all...
 
I have a weird use case where a network connection object needs to kill itself when it gets a disconnect message. So the "onDisconnect()" method tells some connection manager to remove it from the set - which destroys the object. So when "onDisconnect()" returns, the object no longer exists.
 
nwp
@Mikhail where do you put the isalive?
 
10:09 PM
MyClass:doSomething(){if(is_alive){//logic};}
 
Where does is_alive live?
 
in the object
 
@nwp Are you complaining compilers won't do the totally retarded thing and not enrigester variables or actually not inline anything? What would that look like? And what purpose would it serve?
 
Nooooo, zombie objects are evil :(
9
 
The object is dead. Deallocated.
 
10:10 PM
@Mysticial Can you replace the handle by a pointer and check if the pointer is null?
 
nwp
@Mikhail that would be UB because is_alive is dead
 
@Mikhail weak_ptr / shared_from_this
@nwp nice and pointed
 
nwp
@sehe I have an assert_equal function that takes 2 arguments and does assert(a == b);. The whole point of the function is to look at the values of a and b when the assert fails.
 
Yes.
 
@nwp Umm...you do realize that placement new doesn't actually allocate anything, right?
 
10:12 PM
So, what's the problem?
 
nwp
@JerryCoffin yes, I was a little unsure if "allocated" is the right word... "has been created" probably fits better
@sehe the assert fails and I cannot see the value of a
 
@Mikhail It's not necessary in this case. The last thing in the "onDisconnect()" method is the call that indirectly destroys the object. So it won't be accessing anything in the object.
 
@nwp Looks like you need more than the assert. The assert is for notification. If you need trace, add it :( I'm mildly surprised you can't see the value (unless you accidentally compile a release build?!) but perhaps it's your timing (try to inspect before the assert e.g.)?
 
nwp
the weird thing is that this usually only happens on clang, but now it happens on gcc too
hmm, if I go up the stack to the calling function the object is visible... maybe just a bug in how Qt Creator asks GDB about values in templates
the funny thing is, when I had the assert in the calling function it wasn't visible there
debuggers and compiler optimizations are black magic, just pray and be thankful when they work
 
10:29 PM
@Mysticial Standard says very little about it. Normal practice is: need for it is fairly unusual, but your usage isn't unique or particularly unusual either. James Kanze used to talk fairly regularly about software for a telephone switch, where each call was an object which destroyed itself when parties on the call hung up.
Oh, that wasn't a hypothetical system either--in fact, it handles a substantial percentage of long distance calls that go out of, into, or through substantial parts of Europe.
 
@JerryCoffin woah
I figured it can't be that rare. I found a few SO questions about it, but none of them mentioned anything about the standard.
 
@Mysticial the exact rules on how you can use a pointer or reference after destruction of its target and what for are fairly boring, but the gist of x.foo is that x must be referring to a valid object of appropriate type—which is not the case after destruction
 
11:03 PM
@Mysticial If it's about delete this why would it? It's just a regular delete-expression.
. @troyhunt I like how their visualization confirms the nature of the pissing contest :)
 
nwp
I'm doing std::cout << stuff << '\n' << std::flush; just to avoid std::endl ...
 
Ell
Why?
 
std::endl is cancer
 
Ell
11:20 PM
It is equivalent to "\n" << std::flush is it no
 
nwp
it is, but too many people use it when they actually mean '\n' so it got a (mostly unjustified) bad reputation
 
std::endl is good for print debugging
Which is 99% of cout's use cases ;P
 
@Ell In many contexts, '\n' already achieves the flush (text streams on linux eg.)
Oh. Upgrading my mom's accounting software I ran into this beautiful screen (no clue why and what purpose it serves):
I thought it kinda epic, and figured it was just because I was on the "Programmers tab".
Erm. Nope:
Needless to say my recommendation has been to start thinking about migrating away.
 
nwp
I feel like when I write while (i--){ vector.push_back(); } the optimizer should take care of adding vector.reserve(vector.size() + i); before that loop if useful instead of me doing it manually.
or take more liberties with the growth factor to make the first allocation happen to be the exact size I will need, based on analysis of the program, whenever possible
 
11:35 PM
Alright... Looks like I have work to do tonight:
 
@Mysticial Youre going to fill all of them with porn?
 
No. If I wanted to do that, they'd be 8TB drives, not 2TB.
 
@nwp lol. you do? You were complaining about the optimizer taking too many liberties earlier
Compiler land != library land. Well. For 98%
 
nwp
@sehe I was complaining that the debugger isn't able to find symbols even though I disabled optimizations
 
yeah. well. I'd be seriously pissed if my debugger ran through reserve() with zero code triggering it
But. You know. You can totes use append(first, last) or assign(first, last) and insert/emplace overloads and they will do it (or the equivalent)
 
nwp
11:39 PM
it would probably an -O3 level optimization where the debugger doesn't really know where anything is anyways
also the call would be inlined, so you wouldn't see much of it besides the memory allocation
 
That changes nothing. It wasn't about debugging, sorry if I made you think I meant that.
@nwp The (conditional) allocation is the thing.
 
nwp
you are using push_back on a vector in a loop and it is out of capacity, a memory allocation is to be expected
 
I'm not.
Doing that.
:)
 
nwp
ok, apparently we are talking about different things
 
@nwp vector.insert(vector.end(), i, v);
@nwp Nah. You're accusing me of writing that code :)
If I can't avoid writing it, surely I wish to control the reserve. I've made generic container traits to help me do it for reservable containers (IIRC Boost Serialization also does it for e.g. flatmap etc.)
 
nwp
11:45 PM
@sehe that is a good point actually
 
@Borgleader Most of the drives in my 16 HD box are almost 8 years old now. And they're showing their age with tons of CRC errors and reallocated sectors.
 
nwp
I'm just not sure how to do that with threads.push_back(std::async(std::launch::async, thread_handler));
probably something about std::fill or so
 
So I went shopping for some replacements. 2TB @ $64 each was a sweet spot.
I was originally gonna get just 3 or 4 of them. But Newegg has a limit 5 per customer. So I was like, fuck it.
 
@Mysticial Why buy one when you can get get two for only twice the price? :-)
 
Speaking of big drives, I'm in need of another 8TB drive for my Anime. But those are still ridiculously expensive.
@JerryCoffin They also had a volume discount.
So I went ahead and maxed out my order.
I haven't bought anything computery in almost a year now. So I had to do that.
 
11:49 PM
@Mysticial You obviously need that new (well, not available yet...) Segate 60 TB SSD. Should hold at least a year or so worth of anime...
 
8TB drives are still $250.
I paid $320 for these 5 x 2TB drives. No tax for out of state.
No shipping either. lol
 
@nwp yeah, it'd be manual reserve with std::generate_n(policy, first, count, gen) or similar c++17. But that leaves the reserve your responsibility (you want that, because you want to control when it happens)
 
@Mysticial I've been wanting to buy some PC parts, but the "shitty CAD tax" makes everything expensive :(
 
nwp
@sehe I found generate_n, but I suppose giving it a back_inserter will not reserve
 
I already said that
 
11:53 PM
@Mysticial That works out to $32/Gig for the 2 TB drives, and $31.25/Gig for the 8 Gig drive.
 
I care more for the combined speed in this case.
I looked at bigger drives since I can re-purpose them for other uses in the future. But everything over 3TB is too expensive if I'm gonna buy them in mass like this.
So these 2TB drives will live and die as compute drives. I may use them as boot drives in the future. But seeing as how SSDs are getting cheap now, that probably isn't going to happen.
 
@Mysticial I guess I'm badly overdue. Last built a new machine in (looking....) January of 2014.
 
nwp
so I replaced my trivial little while loop + push_back with std::generate_n + back_inserter + lambda wrapper... and it doesn't actually solve the issue
 
@JerryCoffin That's not too bad. My main box is December 2014.
 
nwp
sometimes I doubt the promised readability increase of standard algorithms
 
11:58 PM
Woah...
These new drives are fast.
Compared to my old ones.
 
@Mysticial My last one before that was...December 2006.
 
I guess that's what higher density does.
 
@Mysticial I guess--still rotates the same speed, so more on one track == higher bandwidth.
May also help that it isn't repeating every read 5 times because using it for compute trashed the drive in only 3 months... :-)
 
@JerryCoffin Yeah. I looked specifically for the 7200 RPM ones. The benchmarks I found online are saying 150 MB/s. (My current drives get around 120 MB/s at best. Usually less.)
 
00:00 - 19:0019:00 - 00:00

« first day (2132 days earlier)      last day (2833 days later) »