« first day (1489 days earlier)      last day (3451 days later) » 

2:00 AM
@NoobSaibot it originated from C
This article describes the calling conventions used when programming x86 architecture microprocessors. Calling conventions describe the interface of called code: The order in which atomic (scalar) parameters, or individual parts of a complex parameter, are allocated How parameters are passed (pushed on the stack, placed in registers, or a mix of both) Which registers the callee must preserve for the caller How the task of preparing the stack for, and restoring after, a function call is divided between the caller and the callee This is intimately related with the assignment of sizes and formats...
@Mysticial You code a routine as it should be, but then overwrite the first few bytes of the machine code (in the assembly itself) with a jump to the initialization routine. The initialization routine then gets called the first time the function is called, and then within the initialization routine you overwrite the jump back to what the code should be (at runtime)
 
user1646075
@NoobSaibot That's basically a no-op
 
damnit, bjarne has like all his books on google playstore, except the one i want (design and evolution of c++)
 
user1646075
x86 supports 'Pascal' convention (function cleans stack, not caller) because it has a magical 'pop for return and remove N other stack items too.
 
user1646075
C is traditionally 'caller cleans the stack' because the number of params is not completely guaranteed.
 
user1646075
Also on a processor with a shit-load of registers, it's common for the first N word-sized parameters to be passed in agreed registers.
 
Ell
2:02 AM
What with varargs
 
@orlp Are you talking to me?
 
@aclarke I don't know of any current C or C++ compiler that supports Pascal calling convention. Pretty much disappeared with MS-DOS.
 
I should probably study some assembly.
 
We need plutonium batteries, so our electronics would last 35 years without recharge.
 
2:03 AM
@orlp I guess it's the first paragraph of this answer that confused me.
 
Is assembly nice?
 
user1646075
@JerryCoffin yeah, but then again, the fortrans &c probably use that convention. it was called Pascal convention, but the MS languiages on 86 used it for their COBOL, FORTRAN and other medieval languages
 
@aclarke Also common on x86-64, despite the relative shortage of registers. Some compilers did it in 32-bit x86 code as well, though only for a few parameters.
 
user1646075
@Jefffrey no. Or yes if you like that sort of thing.
 
I want the Mill calling convention :(
 
2:04 AM
The asker wants to use C to solve a problem, and the answerer seems to say that the nature of C disallow's this due to calling conventions...?
 
user1646075
@JerryCoffin yeah, didn't some exploit the indexing registers sometimes?
 
@NoobSaibot we are talking at an assembly level, not C level
 
user1646075
x86-64 has how many new registers? The last processor I tried to learn was PA-RISC but I didn't achieve it...
 
@NoobSaibot all this is undefined at a C level
 
@aclarke Which indexing registers? Borland used SI and DI, if that's what you mean.
 
user1646075
2:05 AM
them yeah
 
user1646075
i forgot their name :-) whoops.
 
@JerryCoffin Are you sure about this? Nonlocal jumps don't preserve the stack...or does it?
@orlp Ohh...
 
@aclarke x64 has R0 through R15, of which R8 through R15 are completely new.
 
user1646075
@NoobSaibot setjmp has to preserve enough stuff so that it can magically disappear anything that lands on the stack in between setjmp and ... it's friend ;-( Typically PC, SP, BP on 86 but possibly more depending on the compiler.
 
user1646075
also setjmp would play absolute havoc with C++ unless it's been heavily augmented to behave itself.
 
2:08 AM
@NoobSaibot They preserve variable that are local where setjmp was called, but not what's local to where longjmp was called.
 
user1646075
@JerryCoffin Nice about time intel got a useful number of registers. Not that I care any more.
 
user1646075
long jump effectively cuts the knees out of the stack, restoring back to when setjmp was called to record the critical data. It's quite violent, but a fast death.
 
@aclarke intel CPUs have a lot of rename registers though
 
user1646075
anything that's local in the function that called setjmp are still there on the stack, oblivious to the carnage that just happened above them.
 
@orlp Learning how to utilize them takes some practice.
 
user1646075
2:10 AM
@orlp like AX = R0, BC = R1, etc?
 
user1646075
@Mysticial yeah, leave it to the compilers! Assembly only for horribly critical or wierd pieces of code. Then lock it in a cupboard
 
@aclarke if compilers weren't so stupid at times...
compilers sometimes blow my mind with the code they generate
sometimes out of genius, sometimes out of despair
 
user1646075
oh right, secret clone zombie registers so that out-of-order can proceed?
 
@aclarke This and pg. 454 here seem to have confused me...
 
2:13 AM
sort of
 
user1646075
@orlp close enough. I hardly care any more
 
@aclarke it's basically where you spend most of your power in your CPU
 
user1646075
young me would be furious at that attitude.
 
I knew coming here first was a good idea. Learning a lot. :-D
2
 
user1646075
@NoobSaibot we could be completely bullshitting you.
 
2:14 AM
@aclarke Yes--I'm sure recent ones have more, but even all the way back to the Pentium Pro they had 40 rename registers.
 
user1646075
woof! I've missed so much.
 
@aclarke I'd still learn what to look out for, for next time. ;-)
Lemme start drafting my question for SO-proper. Thanks all!
 
user1646075
@JerryCoffin presumably the assembly codester doesn't get to nominate the rename registers? It's all working under the hood in the pipelines?
 
user1646075
@NoobSaibot mention setjmp along with C++ tag. That'll make you popular.
 
@aclarke if you could nominate rename registers they wouldn't be rename registers anymore
 
user1646075
2:17 AM
my goddamned network is goddamned again.
 
@aclarke Correct. Well written code can still be aware of them though (e.g., realizing that it will recognize xor reg, reg as clearing reg, so it can compute what's before and after that in parallel).
 
@aclarke Goddamnit.
 
user1646075
@Nooble I do. Almost daily.
 
oops
found a bug in my erase code
protip: move first, then destruct
 
2:18 AM
@MissJ. There are no native datatypes that can store hold a number that's 4 million digits long. — Mysticial 56 secs ago
 
otherwise you're destructing elements, then moving into uninitialized memory :P
 
@aclarke You need to sacrifice more virgins (to me). As always, remember that I'm much more picky about young, female and gorgeous than actual virginity.
 
user1646075
@Mysticial Is mayonnaise a data type?
 
@Mysticial please don't hate on my 13287713 bit machine
 
user1646075
@JerryCoffin If I find a virgin, I'll perform the ritual. Initiation can't be rushed.
 
user1646075
2:20 AM
You need to tick all the boxes.
 
ooooooooooh snap
 
user1646075
/groans at self
 
user1646075
@orlp regarding.... see the end of each line? hover and you see an arrow. Click it to refer to another message.
 
@aclarke glorious gif or gtfo
 
@orlp I wonder if I still have that VHDL around. I once actually wrote up a simple 2048-bit CPU and ran it on an FPGA.
 
2:23 AM
@JerryCoffin you needed enough address space to address all possible 11 dimensions of string theory?
 
user1646075
And now I must eat. So hungry. Damn you @Jefffrey and your luscious looking pastrami wrap.
 
it's a piadina
 
@aclarke No, horse radish isn't a data type either!
 
@Borgleader Performance, no? — anon 3 mins ago
 
2:26 AM
@JerryCoffin Since setjmp.h is for unrolls the stack, wouldn't this necessitate that the stack be contiguous, or at least push frames at addresses greater than the abs of the caller's address?
 
jeez
 
@orlp Designed specifically for the matrix reduction part of a General Number Field Sieve. Bob Silverman stated as a fact that nobody would ever build such a thing--so I did.
@NoobSaibot No, not really. For example, it works perfectly well on x86, which grows the stack downward in memory. Also works on IBM and Cray mainframes that don't have stack hardware, so they build stacks as basically linked lists of stack frames. That probably makes it more complex, but it can still be implemented.
 
@orlp: ...And just to be clear, i should treat "C declaration" as just the name of a calling convention--independent of whatever language is used, right?
 
@NoobSaibot correct
 
@JerryCoffin So then these people are all liars.
@orlp Ok! Seriously, that was confusing...thanks!
 
2:32 AM
@NoobSaibot Looks to me more like confusion on your part than dishonesty on theirs.
 
@JerryCoffin That was a joke, but yeah. Point taken.
 
@NoobSaibot Ah, that's the problem. I have no sense of humor. Everything I say is 100% serious.
 
2:43 AM
Hmm...my post just seems to have gotten up-voted before I finished posting it.
 
2:56 AM
Warning, possible stupidity below:
Could an ELF file be used as a replacement for DLLs?
 
@Borgleader Yes, probably. Microsoft uses PE files, which are a variant of the older COFF format, but have added enough to have pretty much the same capabilities as ELF.
 
user1646075
@NoobSaibot looks like the explanations were a bit obtuse, (but I didn't read all the way down..)
 
3:15 AM
why does cppreference say The element is constructed in-place, i.e. no copy or move operations are performed. for std::vector::emplace?
 
because that's what happens lol
 
from what I can see you do move it into place
 
look at the example in the page
 
 
this one then
hm
 
3:17 AM
@Rapptz consider that position already constains a constructed element
@Rapptz you will move out of that element, but the element at that point is still alive
 
the element is constructed in place.
It doesn't say anything about the other elements.
 
looking at the libc++ implementation they construct into a temporary then move assign it in
 
not standard conforming
 
why not?
 
it's supposed to construct it in place?
that's the entire fucking point
 
3:19 AM
the standard just says "Effects: Inserts an object of type T constructed with std::forward<Args>(args)... before p."
 
tch.
 
"Requires: T is EmplaceConstructible into X from args. For vector and deque, T is also MoveInsertable into X and MoveAssignable."
I don't see anything that indicates it's supposed to be constructed in-place
@Rapptz emplace_back doesn't seem to require MoveAssignable, so I guess it's intended to be constructed in place there
@Rapptz but in-place construction doesn't make sense in the middle - there's already live objects there
 
k
 
should we edit cppreference?
 
I consider that a defect btw
 
3:24 AM
@LightnessRacesinOrbit Your presence is requested in the Tavern. chat.meta.stackexchange.com/transcript/message/2651240#2651240
 
@Rapptz emplacing in the middle would require you to destruct live elements
 
-1
Q: Where and how to find the best c++ documentation

Charles HetterichObviously one of the most important skills in programming is being able to quickly find answers to your questions. And c++ is a language that has a huge amount of important information, from knowing how certain every key word works to how the CPU manages its memory, that all intertwine and affect...

 
what the fuck feeds
seriously
 
close it
feeds has a feed for
Who the fuck flagged it?
 
I'm conflicted on what to close it as... it's opinion based, too broad, a tool rec...
 
3:27 AM
@Rapptz I flagged it as spam
 
don't be stupid
@hichris123 tool rec
 
@JerryCoffin Neat, thanks.
 
user1646075
@JerryCoffin Actually I thought one of the reasons C and especially C++ tried to lock down known numbers of parameters was precisely to allow simpler/faster calling conventions, such as not having caller-cleans, or being able to rely on registers. Original C was seriously callous about such things, even disregarding varargs. IIRC one some machines you could do varargs without actually doing varargs, but just exploiting the nature of the generated code. Such frivolous times!
 
well varargs isn't particularly neat either
"poop it all on the stack and pray the other side can decipher the sizes correctly"
@Rapptz I think the only reason std::vector has emplace in the first place is to conform to the generic interface that other containers might have more optimal implementations for
 
user1646075
but at least it carries no baggage!
 
3:37 AM
@Rapptz but cppreference should be edited, lets see if I can
 
user1646075
read up about any general purpose interpreted language. There's a lot going on under the hood.
 
@Rapptz oh I can't edit it because it uses the generic container emplace template
 
3:50 AM
but... this makes no sense at all coliru.stacked-crooked.com/a/dd0b880aebaab01c
 
user1646075
@chmod711telkitty now you're a person? What happened to fat horse? Glue factory?
 
I am a shape shifta ... If I suck in, all fat goes to chest n buttocks
 
user1646075
@chmod711telkitty so you should have blue skin then. You're lying.
 
user1646075
I know what it was - your horse was that one from the melbourne cup...
 
But I am lazy so the fat stays where it is 😱
 
user1646075
3:58 AM
as long as you wear it well.
 
🍰🍕🍟🍔🍗🍦🍮
Sry ... Got carried away by the emocons on my mobile 😖
 
user1646075
@chmod711telkitty all I see are boxes.
 
user1646075
but mark is hungry
 
user1646075
4:04 AM
shouldn't emocons be all black, with the occasional trickle of blood from their slashed arms?
 
Win 8 devs nothing else to do but colored emoticons.
 
user1646075
@MarkGarcia oh yeah - I rofl'd recently at a declaration that "this is the year of emoji!" by some breathless development commentator
 
user1646075
clearly all the software the world ever needs is written, and now we just need stupid icons and another colour scheme
 
@aclarke C++ got picky about the number of arguments (and specifying them all in the declaration, etc.) mostly because it was necessary for function overloading. It's pretty hard to sort out which function to call based on parameters if you don't know the number and types of the parameters.
 
the problem got solved though lol
they placed variadic templates as the lowest priority in overload resolution
 
user1646075
4:15 AM
@JerryCoffin oh yeah, and that. But C did get picky for...
 
user1646075
the old ioctl(x, y, z) function was a classic. if x was a certain value, only y was needed. And it didn't use varargs to sort out the mess originally.
 
@aclarke Mostly for the sake of giving better assurance that code was correct, and any necessary casts would be handled automatically.
 
user1646075
@JerryCoffin and better code. All of the above!
 
user1646075
probably any function with a clean sig could explout the so-called pascal convention.
 
@aclarke I followed the C89 standardization process pretty carefully, and don't recall better code being mentioned in any of the papers advocating for adding prototypes to C.
 
user1646075
4:17 AM
at what era did ftn(void) become a thing so that it was really clear no params were expected?
 
Admittedly, my memory's notoriously poor, and I could have just plain missed it, but...
 
what the fuck is the point of allowing void f(int...) be a valid declaration
 
@aclarke When prototypes were added (which was in C89, but present in most compilers before that--probably around '86 or '87 if memory serves).
 
user1646075
@Rapptz the int can tell you how many more things are in ... - the signalling param doesn'ty have to be a string
 
user1646075
@JerryCoffin ok.
 
4:19 AM
what?
f(int...) is equivalent to f(int, ...)
 
user1646075
oh that grammatical thing. Yeah, good Q
 
this stupid thing ruined everything
 
user1646075
might have been a fight in the C89 process; Jerry?
 
:(
 
user1646075
let's blame Microsoft for doing it differently. May not be true, but who cares?
 
4:23 AM
@aclarke C89 doesn't allow the int... thing. It requires the comma to be present. The int f(int...) was used with the macros in varargs.h that preceded stdargs.h. I'm reasonably certain Microsoft did support it at the time, but it wasn't "differently" then--it was how pretty much everybody (including the compilers on Unix) did it at the time.
 
4:54 AM
if for some reason during the constructor of my cdeque an exception gets thrown (for example by an element constructor, should I always try to catch that and free the memory I allocated?
 
user1646075
yes?
 
k
wasn't sure
 
user1646075
you need to be very careful about ordering of the activity. many traps lurk.
 
I'm aware
 
user1646075
sounded like you're asking if you should allow a leak...
 
user1646075
4:57 AM
that should only be allowed in long running kernel code.
 
basically how I write this code is in an iterative manner
I just keep scanning over the file top-to-bottom scanning for issue/filling in missing pieces
and sometimes I focus on noexcept specifiers, then on exception safety, etc
 
TIL of it's name. Modern version would be hard drives/SSDs.
 
@aclarke it gets tricky though
@aclarke for example when I move from another cdeque using the move constructor with an explicit allocator instance argument, and the two allocator instances do not compare equal I have to move all the elements to a new storage location
@aclarke then afterwards I clear the moved-from cdeque and deallocate its memory
@aclarke but what if destructing the elements from the moved-from cdeque throws an exception?
etc etc
 
user1646075
exactly!
 
I'm very good at that type of thing though
I can usually spot those from a mile
I just spend a lot of time thinking what I actually should be doing
 
5:09 AM
Ffffff#*^¥£%#}!!! Forgot I got cash & cards in my coat before I washed it!
 
oops
rip cash & cards
2014-2014
 
user1646075
@chmod711telkitty damn! they should survive though... what state ?
 
Only remembered it just now & it's dry & back in my wardrobe for a while already @_@
Not sure, have to check when I get back ...
 
user1646075
hope your washing machine doesn't have a card reader. God knows what will arrive by courier in the next few days
 
5:22 AM
@orlp I reworded emplace a bit for you
 
@Cubbi while it's definitely better, I'm not sure if it's entirely truthful
@Cubbi consider the fact that there already lives an object at *position
@Cubbi the implementations I've looked at (libc++, stdlibc++) construct in a temporary and move assign it to *position
 
Right, when I am more awake, I'll try to write a note explaining why.. or you do it
(that temporary location is still "location provided by the container")
 
"in-place at the location" seems to suggest it would be constructed at *position
maybe reword that to a location?
I reworded it
 
more importantly, emplace_back is missing type requirements (I bet because someone tried to grep the PDF for it, but it's emplace_- in table 101)
 
yeah I don't necessarily agree with using - to break identifiers in the C++ standard document
@Cubbi perhaps if you're familiar with the standard you could take a quick glance and see if you happen to know the answer to this?
0
Q: May the elements in a std::vector have a throwing destructor?

orlpWhen I look at the Container requirements on cppreference it lists Destructible as a requirement for value_type. This seems to imply that destructors of container elements may not throw. I haven't been able to find a citation for this requirement in the C++14 standard (haven't looked in older ve...

 
5:42 AM
@orlp sounds like a straightforward case where the standard is right and the wiki is wrong.
 
replace the second tag with language-lawyer
 
Another user created that concepts/Container page (but my fault in never checking in two years)
(in his defense, concept/Eraseable didn't exist until this year)
Have fun throwing those exceptions
 
@PeteBecker: There's no better way to arrive at a bad conclusion than by beginning from a mistaken premise. Within a limited scope, templates are exactly the sort of "magic hammer" you're describing: they're the mechanism for doing metaprogramming in C++. But the bad premise is that you should be coding in C++ in the first place. That's a horrible idea for any number of reasons, and we've known it for decades. C++ may not be the worst language ever invented, but without a doubt it's the worst ever to be taken seriously! — Mason Wheeler 5 hours ago
 
user1646075
@Rapptz REE-OWWWRRR!
 
user1646075
Ooooo - Mason is a Delphi programmer. Way to pick the winning path.
 
5:56 AM
lol I noticed that too
 
user1646075
There's something about Pascal programmers, sniffing about the proper way to do things with only a toothpick, a jar of peanut butter and 3 staples. I bet he has a neck-beard.
 
TIL there's eval $str
I hope this works exactly how I hope
 
user1646075
A neck-beard and a turtleneck sweater.
 
user1646075
in Perl? Sure does! minor scoping to care about.
 
nah in bash
 
user1646075
5:59 AM
ahhhh. Sure does! Meta-quoting is a pain in the ass
 
better to use quotes I think: eval "$str"
 
user1646075
hmmmm - should be sufficient.
 
user1646075
don't recall ;-/
 
I have no idea why this script keeps giving me errors
I really hate shell scripts.
 
user1646075
what shells need now is AST and methods to manipulate
 
user1646075
6:03 AM
gist it. Although I have to go home now... someone can surely help
 
it's the command line processing bit
I think anyway
 
user1646075
quick! I have to pack and shutdown some VM's
 
lol it's okay
I'll just struggle through it
I'm not in a rush
why does it execute grep
._.
do shell scripts just execute these programs in parallel rather than linearly?
the grep call at the bottom of the file shouldn't be called
 
user1646075
sorry, you must reveal...
 
6:06 AM
when using bash, you can use set -x to enable command tracing
 
user1646075
:wq
 
this is always called
 
@rightføld It turned out to be more of a float/char/boolean talk. And I only had 45 minutes.
 
@StackedCrooked neat
 
6:43 AM
@FredOverflow have faith in your students, they are not in high school. you are not teaching them how to walk, just bring a whip & they will show you that they are capable of running. if some of them can not, well, you will have a new group of monkeys to try your whip on
4
 
@Rapptz Yes, the | makes the shell execute all the processes in the pipe in parallel.
 
@VáclavZeman The issue was something else.
Also not what I meant.
 
6:58 AM
@Cubbi so much fun (I am on the checking end)
 
7:11 AM
@aclarke As far as I can tell, he's not really a Delphi programmer nearly so much as a Delphi fanatic. His answers have a lot of "Delphi is the answer to all programming questions", but almost nothing of "here's Delphi code that's cleaner/better than you can write with anything else."
The few times I've seen him actually post code, it looked mediocre even by the standards of Turbo Pascal 4 (the last time I used Pascal...)
 
7:24 AM
I have a stupid question I've been meaning to ask.
Why is void* the generic pointer and not char*?
Can't you cast to and from char* just fine?
 
void* cannot be dereferenced/read-from.
 
@Rapptz because if char* was the generic pointer then dereferencing it wouldn't be an error
 
highfive
 
@Rapptz and you do want dereferencing a "generic pointer" to be an error
@MarkGarcia BAM
 
okay
 
7:30 AM
Hm. I like to call void* just-a-pointer.
justapointah
 
@Rapptz Just for what it's worth, at one time it was the generic pointer--for example, at one time malloc returned a char *.
 
@JerryCoffin I'm really confused what I should do when element destructors throw exceptions in various scenarios
for example, what should I do when an element's destructor throws in my the containers destructor?
1. nothing, just let the exception flow through (other elements in container never get destroyed, memory not deallocated), 2. always still deallocate memory (other elements in container never get destroyed and now no longer have a memory location either), 3. attempt to continue in some way, calling other elements' destructors (what if those throw too?)?
 
7:45 AM
undefined behaviour
or assert to make sure destructor is nothrow
 
@Rapptz but the standard doesn't require that: stackoverflow.com/q/26902006/565635
 
@orlp There is no really good thing to do at that point. My first choice would be a concept to assure it can't happen. Second would be to call abort. Third would probably be to eat the exception and continue on.
 
I'm even more conflicted in the move constructor
 
The standard says it's undefined behaviour.
 
@Rapptz where?
 
7:52 AM
oh wait no
it says nothing happens
as if the function is never called
> If an exception is thrown other than by the copy constructor, move constructor, assignment operator, or move assignment operator of T or by any InputIterator operation there are no effects.
 
@Rapptz which function are you talking about now?
 
any of the modifiers
emplace, emplace_back, etc.
 
yes
that's the strong exception guarantee
that's (relatively) easy
 
then what's your question?
 
I'm talking about the constructor/destructor
 
7:53 AM
@orlp Again, the best course is to just say it needs to be nothrow.
 
if something throws in the destructor that's the user's problem
 
the most conflicted feeling is when I've succesfully move constructed my object and I'm cleaning up the moved-from object
and then bam exception
 
@orlp Should that not be left to the moved-from object's dtor?
 
the standard doesn't even specify anything for the destructor
I can't find anything about it
23.3.6.2 just lists assign and some of the constructors
it feels like an entire page is missing
 
@VáclavZeman you could
@VáclavZeman the moved-from object only has to be in some valid state
@VáclavZeman I don't know if a container filled with moved-from objects counts as "valid state"
 
7:56 AM
how is the standard so underspecified here
 
I don't understand either
it frustrates me
 
@orlp I think it should.
 
@VáclavZeman I think the most sane behaviour is to have a moved-from container be empty
 
@orlp Well, that is true if you move the whole container but if you move just the elements then container of moved-from elements should be fine.
 
@VáclavZeman this is the move constructor of the container we're talking about
@VáclavZeman often you can just move the few memory location pointers
@VáclavZeman but not if alloc_traits::propagate_on_container_move_assignment::value is false and the allocators do not compare equal
 
7:59 AM
Honestly.
 

« first day (1489 days earlier)      last day (3451 days later) »