« first day (444 days earlier)      last day (4497 days later) » 

11:00 PM
@kbok generally if I think I need placement new, it always turns out I need an allocator class instead.
 
> Although this syntax works too, it would force you to use reinterpret_cast instead of static_cast to convert char * to Widget *. As a rule, prefer static_cast when possible.
 
@MooingDuck Yes. But i'm wondering if this is actually valid. The standard seems to say that the allocated memory for an array is more than count * sizeof(T)
 
Right.
@kbok No, that's about new[].
 
But placement new doesn't need any overhead.
 
> new T[5] results in a call of operator new[](sizeof(T)*5+x)
 
11:01 PM
 
An array object always uses exactly count * sizeof(T) bytes.
 
You need to call destructors yourself anyway.
 
^ This is the opposite of hallelujah!
 
IT CHANGED. MAGIC.
 
@kbok all dynamic memory has an overhead. Placement new isn't dynamic though. No space overhead
 
11:02 PM
It is!
 
Placement new[] would be just convenience, and didn't attach any magic.
 
Actually it is not. It's a lame trick. But I won't tell you how I did it.
 
@MooingDuck That makes sense, but the argument to operator new must be the exact size of the requested object (overhead doesn't matter) except for arrays. Why is that ?
 
evening#
 
> A new-expression passes the amount of space requested to the allocation function as the first argument of
type std::size_t. That argument shall be no less than the size of the object being created; it may be
greater than the size of the object being created only if the object is an array.
 
11:04 PM
morning
 
@kbok Because delete[] needs to know how many destructors to call.
 
@kbok because it wouldn't be an array if there was only enough space for one of the object. An array needs enough space for more than one object.
 
Because.
 
@RMartinhoFernandes still talking about placement new I think
 
@StackedCrooked You really like hipster music, eh?
 
11:04 PM
Placement new doesn't call operator new.
 
@EtiennedeMartel Hipster? That never occurred to me. I just like the sound of it.
 
@MooingDuck Yes, but here the object is an array.
 
I'm a sucker when it comes to fancy little melodies.
 
I just like the sound of it. You probably never heard it before.
 
@RMartinhoFernandes So, a little housekeeping can happen here, am I right ?
Thus the need for extra space
 
11:06 PM
I still don't now what this placement array new thing is. I got to read up on it.
 
@EtiennedeMartel Just like this:
 
"hispter music" is the name I give to any music that's classified as "indie pop" by Wikipedia.
 
PLACEMENT NEW DOESN'T CALL OPERATOR NEW.
 
@kbok there shouldn't be housekeeping. I'll check the standard
 
11:06 PM
Anyone else spot that random messages get junk appended that looks out of place?
`when it comes to fancy little melodies.` looks out of place there
 
@RMartinhoFernandes it creates an object in a buffer instead of on the stack or on the heap
 
@CatPlusPlus I got it, thanks
 
Sheesh.
 
@CatPlusPlus still a new expression though isn't it?
 
I just feel ignored.
 
11:07 PM
@sehe It's probably a buffer underrun or something like that.
 
Ah, my internet is too fast. Okay, got it
 
This is great too:
 
@kbok 5.3.4 "This type shall be a complete object type, but not an abstract class type or array thereof" You can't placement new an array. You placement new many objects
 
I should probably stop now before I start gathering a mountain of flags (again).
 
@CatPlusPlus Actually the real question is "If operator new can be requested x more bytes, does a placement new have to make up for these bytes as well ? "
 
11:08 PM
No.
 
@MooingDuck I know about "placement new". I don't know about this "placement array new" thing.
 
@RMartinhoFernandes oh right.
 
@kbok Placement new is just "call the constructor".
 
@MooingDuck Oh I see.
 
@RMartinhoFernandes I checked the standard, there is no placement array new
 
11:09 PM
That's a relief.
 
@RMartinhoFernandes Placement new is new without the new.
 
lol
 
@RMartinhoFernandes This thing is yet another non-standard extension.
 
?!?!?!
 
Placement new is new new.
Pew pew.
 
11:10 PM
@kbok show us the syntax, everything you've mentioned can be done with no extension
 
ew ew.
 
@CatPlusPlus New is old. New new is where it's at.
 
#define pew new
 
Placement is the new new
 
New syntax for placement new.
pew (buffer) T;
 
11:11 PM
So. I propose we name it Placement, instead of Placement new to avoid confusing @kbok any further
 
MSVC has new(mem) T[n]
 
@Abyx that's standard.
 
#define placement new
placement (buffer) T;
 
Ok. I should probably be leaving.
 
I actually like how that reads, placement (buffer) T. Not too obvious that a constructor is being invoked, though
 
11:12 PM
placement_new
And suddenly, it's greppable.
 
@sehe I don't think kbo was thinking that placement new called new. Only CatPlusPlus was saying he did.
 
No, I see now that MSVC might be accepting strange syntax
 
huh, didn't know new auto(1); was valid
 
We also could call it old.
 
ABAB ABBA AABB. Which rhyme scheme reminds you most of C++?
 
11:13 PM
Just call it $_. Presto, Perl 7
 
@StackedCrooked ABBA
@sehe what syntax?
 
@MooingDuck I think so too :)
 
unfortunately there is no "placement delete[]"
 
@MooingDuck We don't have the same 5.3.4. Which standard are you looking at ?
 
@kbok C++11 Feb draft
@kbok nevermind, it's there [expr.new]
 
11:16 PM
@MooingDuck Oh nevermind.
I have a problem with paragraph spotting
 
I was just called a very talented C++ programmer. I'm awesome.
 
Ok so we have int* x = new (buf) int[7];
 
@RMartinhoFernandes where. proof?
 
So the guess here is that buf has a size of 7 * sizeof(int).
However, new T[5] results in a call of operator new[](sizeof(T)*5+x) (5.3.4.12)
 
@sehe I can't prove it but the person that said it seemed convinced of it.
 
11:21 PM
@RMartinhoFernandes well, you're not. talented.
 
As @StackedCrooked and I agreed earlier, you should be called 'accomplished' :)
 
@kbok that example isn't using placement new
 
@kbok Wait, I thought we had established there was no such thing. Now you tell me there is?
I'm confused.
 
@sehe Accomplished? In what?
 
11:22 PM
@RMartinhoFernandes Who did that ?
 
@sehe I'm accomplished? I don't remember having accomplished anything.
 
@RMartinhoFernandes you can placement new many objects, it's still the same placement new
 
13 mins ago, by Mooing Duck
@RMartinhoFernandes I checked the standard, there is no placement array new
 
being accomplished, having accomplished. different things
 
@sehe Yeah, I once counted to 52.
I think that's quite an accomplishment.
 
11:23 PM
@RMartinhoFernandes the standard is hard to read. As far as I can interpret, there's only placement new, which can also handle arrays.
2
 
@StackedCrooked oh ffs. stop flauwekul :)
 
@sehe Ok, then what does "being accomplished" mean? I hope it's not an insult.
 
@MooingDuck Sure. What I want to know is how many bytes we need for an array, because I want to placement new an array.
 
@RMartinhoFernandes Me too.
 
11:24 PM
You're a cat. That's not your <some word that means the sound an animal makes>.
 
@RMartinhoFernandes There is no such thing as placement array new, it's not treated differently.
 
@kbok check the size of the target?
 
this is fucking typical
 
@Xaade Yes.
 
@RMartinhoFernandes I can't help it, but I seem to attract gibberish.
 
11:25 PM
I post a question about an algorithm on SO, and nobody answers and I get told to move it to cstheory
where they downvote it and leave no answers
the fuck is wrong with these people
 
@kbok Ok then, if you can place an array object, it's size is exactly count * sizeof(T).
 
@DeadMG you need more karma
 
@DeadMG It's a bit like administration.
 
@DeadMG and less ????? :)
 
@DeadMG Yeah, you already beated the boss of SO.
 
11:26 PM
SO is for answering, not for asking
 
On to the next level.
 
At least I think I understand it. Placement new, means take this target area, and place an object there. Is it all that different from casting a typed pointer from a void* memory allocation?
 
@sehe Didn't yell in the slightest- that was my only interaction there.
 
@RMartinhoFernandes But if that is the case, why is operator new requested additional bytes ?
 
the idiot who commented gave an idiot response, too, because the input to the algorithm is a set, not an array
 
11:26 PM
@Xaade very different. placement new calls the constructor
 
@kbok Because there's an "array new" which is treated differently!
 
@MooingDuck I see.
 
@DeadMG ok, what's your description of 'the fuck is wrong '
 
@kbok that's not placement new. Array new requires overhead, placement new does not
 
@Xaade For an array of objects, it constructs the objects at this place.
 
11:27 PM
@DeadMG forgive them, for they know not what they do
 
@sehe That was here, not on cstheory
 
It needs more bytes because "array delete" needs to know how many destructors there are without you telling it.
 
@DeadMG duh. I knew that
 
well then
 
@kbok Which means it's the correct way of casting an object out of a void* alloced memory.
 
11:27 PM
I can't be downvoted on fucking cstheory for fucking yelling in the fucking SO chat
 
Oh. I see. The chat is made for that. Makes sense.
 
If you intend to cast out a new one.
 
@RMartinhoFernandes The implementation can also hash map pointers to array sizes instead of storing the size in-place
 
@DeadMG Well, but storing it in place is an allowed implementation.
 
oh yes
 
11:29 PM
Lol, I see we have 11 room owners again?
 
@kbok actually, I can't find anything in the standard about placement new constructing stuff in an existing buffer. Still looking. 5.3.4 seems to be entirely about "normal" new.
 
heh.... you can use placement new to make a dynamic C-style array.
 
@StackedCrooked Ooh, someone is bound to be disfrequented...
 
@RMartinhoFernandes Ok, so the additionnal bytes are not part of the size of the array object ?
 
@kbok Exactly.
 
11:30 PM
@MooingDuck What about 5.3.4.11 ?
 
@RMartinhoFernandes I copywrited that. My lawyers will be contacting you.
 
@kbok R.MartinhoFernandes is talking about dynamic new, not placement new into a bufer
 
@RMartinhoFernandes Okay, thanks :)
 
@StackedCrooked I don't think we went down to 10
 
@kbok what about it? That doesn't even mention constructors.
 
11:30 PM
@MooingDuck The description of operator new with the placement new signature states that it intentionally does nothing. That's enough.
 
@DeadMG I think that this morning it was actually reduced to ten.
 
also thinking about algorithms reminds me of university
fuckitty fuckitty fuck fuck shitballs, I hate university
 
I concur.
 
new expressions call the corresponding operator new followed by the constructor. So placement new intentionally does nothing, followed by calling the constructor.
 
@CatPlusPlus "concur" as in "concurrency"? ;)
 
11:31 PM
frequently in room is not a good estimation. All I had to do was close and open room lots of times, and I'm frequent again.
 
@DeadMG So why did you start University?
 
@Xaade I don't think that's the algorithm used.
 
@Xaade you think too little of yourself.
 
@RMartinhoFernandes I wasn't frequent this morning. I'm frequent now.
 
Oh you are?
 
11:32 PM
Mornings are different.
 
@kbok after all this, and reading the standard, you seem to be right. Placement new-ing objects in an array requires some unspecified overhead.
 
@FredOverflow Because I'll never get a job without a degree
 
@Xaade You just disfrequented someone else?
 
even though they're not even supposed to prepare you for the jobs in question
 
@Xaade testing the hypothesis now
 
11:33 PM
@DeadMG you can come clean my apartment if you like. I'll give you 10 EUR per hour.
 
@MooingDuck I'm starting to think that this is simply unspecified.
 
fuck that shitballs
 
@kbok seems to be :(
 
@StackedCrooked Deal. Be warned that I require Internet access to clean it, and I usually take whole days to clean stuff.
 
Man, this standard is as helpful as a girl talking about relationships.
3
 
11:34 PM
@kbok it's made all the more confusing by all forms of new having placement paremters.
 
@kbok That is?
 
@DeadMG formal education is just that.... formal. I've associated formal with not-real for the time being.
 
@CatPlusPlus Actually, placement new calls void* operator new (std::size_t size, void* ptr).
 
@RMartinhoFernandes FYI, I was not addressing you :p
 
@Xaade then why do all the real jobs require it?
 
11:34 PM
@EtiennedeMartel Not at all
 
that's the thing
the University wants to jack off about how theoretical they are, and they have nothing to do with the real world
fine, let them, I don't care
 
@DeadMG Fractal porn.
 
the problem is that all the jobs want such things, even though it has little to do with what they need
 
@DeadMG Because hiring business in general appears adapted from government standards.... which is to say.... low.
 
@StackedCrooked But I want that job!
 
11:36 PM
@RMartinhoFernandes You can apply on Saturdays between 7 PM and 5 AM.
 
@DeadMG I have a new term. Job-entry-shock. When you're a newbie out of school and suddenly figure out that everyone else fakes working hard.
 
I hate everything. mumble mumble
 
@DeadMG A university degree means that you are willing and able to pull things through.
 
@StackedCrooked Can you say that in real man's hours (none of this AM/PM shit)?
 
19h to 5h (That's when I'm awake and sober.)
 
11:37 PM
@FredOverflow Then, you can say, exchange a university degree, with say, digging holes in shit infested muddy ground.
 
@FredOverflow Then why do they require CS degrees instead of any degree?
also, I'd argue it means that you're a fucking idiot, because you just spent years of your life and much money on something you'll never actually need
 
WTF do AM and PM mean anyway?
 
@Xaade I think it depends heavily on the company
 
After Morning and Pre-Morning?
 
@DeadMG So you have at least a little head start on programming, I guess.
 
11:38 PM
@RMartinhoFernandes It's latin.
 
@RMartinhoFernandes The "a" and "p" stand for "ante" and "post".
 
@FredOverflow But ante what? Ante-Morning?
 
"m" stands for meridiem.
 
Meridiem.
 
@RMartinhoFernandes You can find this (and many other kinds) of information of the internet.
 
11:38 PM
Ah.
 
@kbok I'd argue not. Somewhere in every company is some dipshit, which no one knows exactly what they do (which is in fact nothing), simply because management has no idea what they actually should be doing.
 
@StackedCrooked This is the Internet. I found it here.
 
I'm in the Internet.
 
Anyway, I think I'm off.
At least for today.
 
@Xaade Well, you don't have this kind of problem in a 3-person startup.
 
11:40 PM
Oooh, threesomes.
 
@DeadMG I almost agree with you. Education is dependent on the school you go to. My school prepared me adequately enough, but that's only because most of our professors also held industry jobs.
 
I also don't have to deal with silly management.
 
@kbok From my experience.... you still do. One of those three is pretending to know what they're doing.
 
@FredOverflow do you have any idea why the standard implies (5.3.4/12) that placement-new-ing an array can use some overhead in the buffer? There is no corresponding placement delete to require it. I can see nothing that says that paragraph doesn't apply to placement new.
 
I think education as a whole needs an overhaul. By college, everything you do should relate to the job you will be performing. Colleges like to claim a well-rounded education, but really just offer carbon copies of high school classes.
 
11:41 PM
@MooingDuck The operator new[] it invokes does nothing.
 
I also think, every single degree should accompany summers in internship.
 
Like the goggles.
 
@MooingDuck I think it's because newing an array implies adding a size before the first pointer.
 
@MooingDuck Please turn that into a proper SO question, it sounds really interesting.
 
18.6.1.3, paragraphs 4, 5, and 6.
 
11:43 PM
@kbok What pointer? Arrays are not pointers.
 
@RMartinhoFernandes the sample in question says it will invoke operator new[](sizeof(T)*5+x), where x is an "unspecified values representing array allocation overhead"
 
@StackedCrooked will you please stop pinging me!
@MooingDuck Yes, and that does nothing (for the standard placement new)!
 
Teaching degrees are surprisingly well fit for education careers. Not sure if that's the style of the degree, or the fact that the both teaching degrees and teaching is in the public arena.
 
What?
 
@MooingDuck That's quite scary, how am I supposed to know how much space to allocate for the buffer if placement new[] can steal arbitrarily much?
 
11:44 PM
@MooingDuck I would think the overhead would simply be the process of applying new to each element in the array.
 
@FredOverflow that's the question in issue
 
@FredOverflow Standard placement new[] steals nothing!
 
@MooingDuck PLEASE make a proper SO question!
 
1 min ago, by R. Martinho Fernandes
18.6.1.3, paragraphs 4, 5, and 6.
 
@RMartinhoFernandes it calls constructors past the end of my array
 
11:44 PM
Paragraph 5.
 
@FredOverflow I mean the first pointee
 
If you want to what two awkward penguins sound like then you should listen to this interview. It's the worst interview in terms of awkwardness I've ever listened to.
 
@RMartinhoFernandes that's not the function being called
 
@kbok If you have an int[10], then there are neither pointers nor pointees involved.
 
@MooingDuck Ah, I see. The function in that sample is user-defined.
 
11:46 PM
1 min ago, by Xaade
@MooingDuck I would think the overhead would simply be the process of applying new to each element in the array.
 
If you do new(buf) T[10] it calls an operator new[] that just returns buf.
 
@FredOverflow You can easily get a pointer to the first element. That would make it a pointee.
 
@RMartinhoFernandes nevermind, I was looking at the wrong place
 
Also newing an array produces a pointer to the first element.
 
@kbok Just because you can convert a T to a U does not mean that a T is a U.
 
11:47 PM
@RMartinhoFernandes unless the type is a type that has to construct members.
 
@Xaade Fixed.
 
@kbok But we're not talking about newing an array, we're talking about operator new[] which returns a void*, not a T*.
 
@FredOverflow I didn't say such a thing :)
 
new(buf) T[10] only needs sizeof(T) * 10 bytes in the place buf points to.
 
@kbok Okay, it's just that many people believe that arrays are pointers (which they are not).
 
11:48 PM
@FredOverflow Stupid C-Style pointer decay.
 
@RMartinhoFernandes What's the point of array placement new if it doesn't do anything?
 
@FredOverflow We're actually talking about placement new on arrays such as new (buf) int[n]
 
@FredOverflow It constructs an array?
 
@kbok Yes, and that is not newing up an array.
 
@FredOverflow To construct. If say you were placement new an object that has pointers to members it must new.
 
11:49 PM
@RMartinhoFernandes It does? Didn't you just say it just returns the argument?
 
@RMartinhoFernandes now that I see the bit in the standard you were referring to... WHAT THE HECK? void* operator new(std::size_t size, void* ptr) noexcept; Returns: ptr. Remarks: Intentionally performs no other action.
 
@FredOverflow operator new[] does.
@MooingDuck I'm glad to see it works when people actually read what I write.
 
@RMartinhoFernandes only if it is a simple type.
 
@RMartinhoFernandes How is that constructing an array? I don't see it.
 
@MooingDuck But it's operator new [] you want.
 
11:50 PM
@RMartinhoFernandes the first several times you never gave a section, we were in teh wrong section
 
You're still talking about this?
 
@RMartinhoFernandes er, yes
@CatPlusPlus er, yes
 
Gosh void* operator new[](size_t, void*) returns the second argument.
 
This discussion is taking too long. I'll just assume I will never use such things.
 
@RMartinhoFernandes and does no construction. Who does the construction?
 
11:51 PM
@RMartinhoFernandes after it does whatever the constructor says to do.
 
new(buf) T[10] calls operator new[](sizeof(T)*10 + something, buf) (which does nothing and returns buf) and then constructs ten Ts on the space pointed by what that call returned.
 
@MooingDuck You guys are thinking in terms of simple types like int, which have no constructing to do
 
That clear enough?
@Xaade operator new never constructs anything . It just returns memory.
 
@RMartinhoFernandes oh right. Gotcha. I thought placement new = operator new(...), I didn't realize they were two distinct steps. That explains... everything
 
The only "construction" for primitive types is a zero-init.
 
11:52 PM
@RMartinhoFernandes Right, it constructs the Ts, but there is no "array" to construct, right?
 
@FredOverflow The result is a pointer to an array object.
 
@EtiennedeMartel Only if you say new(buf) T[10]() with the additional parenthesis ;)
 
@RMartinhoFernandes So what the hell is that + something ?
 
@EtiennedeMartel I don't know why you all keep talking about primitives. We're assuming arbitrary objects
 
@RMartinhoFernandes then operator new for placement new is a noop.
 
11:53 PM
@RMartinhoFernandes No, it's a pointer to the first element :)
 
@kbok It's for consistency.
 
@RMartinhoFernandes With ?
 
@kbok "normal dynamic" new
 
@FredOverflow Oh right.
@kbok With new T[10].
 
so, when are the constructors called?
 
11:54 PM
All array new expressions work the same.
 
So @MooingDuck, where's the SO question already? ;)
 
@Xaade the new operator calls operator new, and then constructs them after
 
Yeah, I want my rep.
 
@RMartinhoFernandes Oh. Argh.
 
@FredOverflow pft, it's kbok's question
 
11:55 PM
@FredOverflow Right, but there's an array object at the same address.
 
@kbok yeah, I'll make one
 
I'll be writing my answer :)
 
@FredOverflow It's actually a bunch of questions. And I'm not sure if I would be able to redact it in a sensible way.
 
@RMartinhoFernandes Correct, both a pointer to the array and a pointer to the first element have the same address.
 
Actually, the standard implies that for new(buf) T[10] the + something part is + 0, because it's the offset from buf to the result of operator new[].
 
11:57 PM
@RMartinhoFernandes Then why is there even a +something to begin with?
 
@FredOverflow For consistency :P
Like this it doesn't need to special case placement new[] expressions.
 
in MSVC something == 0
 
It must be to be standard-compliant.
 

« first day (444 days earlier)      last day (4497 days later) »