« first day (505 days earlier)      last day (4425 days later) » 

sbi
3:00 PM
Plus the browser just crashed after I had typed that last message.
 
@rubenvb does LLVM run with PyPy ?
i mean the build scripts
 
good morning
 
Although that's the kind of unstability the snapshot had a few weeks ago. Change a (long-ish) header by adding or removing some lines, then suddenly some TUs arbitrarily crash at compilation.
 
@JohannesSchaublitb no idea at all. Didn't even know about pypy.
 
3:01 PM
Hey, I found someone!
 
Pakistan in the Middle East? I don't think so.
 
@LucDanton debatable
 
damn... guess I'll have to search some more. :(
 
@rubenvb Want to start Asia from the Indus on?
 
@LucDanton Wiki says: Located at the crossroads of South Asia, Middle East and Central Asia, Pakistan has an important geopolitical position in the world.
 
3:03 PM
speaking of Pakistan, I am going there for a month at the end of April.
 
So it's really debatable.
 
@rubenvb Ah well, not only that but I wanted to partition regions across Middle East and Asia. But apparently there's overlap between the two, it's not just a matter of deciding where to put the line.
So my premise is wrong etc.
 
lol, @Xeo 's location is in your code.
 
3:08 PM
"My arbitrary terms are more arbitrary than your arbitrary terms!"
 
@rubenvb i guess for it to support "loadable modules" i need some librt ?
is there a windows real fast version of it?
 
@JohannesSchaublitb no idea what that loadable modules stuff is about. @DeadMG might have an idea.
 
what about him ? the name seems Middle-Eastern, especially Persian.
 
oh
@rubenvb OMG is that gcc4.7 a debug edition?
it's hell slow here :)
 
@JohannesSchaublitb you mean my 4.7.0-2-gcc package?
You can check the CFLAGS on that with gcc -v
at the end of "configured with". Most definitely not a debug version
 
3:12 PM
has gcc added support for lambdas yet?
 
@IntermediateHacker from 4.5, AFAIK
 
@Abyx lol, I have 4.6, and I didn't know my compiler supported lambdas. :D
 
@IntermediateHacker <Facepalm>
Clang has em now too. Haven't checked 'm out yet though
 
@rubenvb hey, your profile says you're a physics student. Do they teach C++ in Physics too?
 
some schools require it
 
3:18 PM
.... A @JavaProgrammer in a C++ room?
 
its a dumb user name when i first came on
im a computer science student and im learning C++ now due to transfer universities
 
im just trying to survive in this world
 
@rubenvb what format do those *.a files created by mingw have?
are those just .o PE files put into .a archive?
 
sbi
BTW, the book question is closed again. Anyone here with close vote privilege, who has not previously close/reopen voted on it, to reopen it?
 
3:22 PM
the close reason says "We expect answers to generally involve facts, references, or specific expertise; this question will likely solicit opinion, debate, arguments, polling, or extended discussion."
if that is what the owners of stackoverflow.com expect, then surely the question is offtopic
since whether a book is good or not is opinion and open to debate
 
@JohannesSchaublitb yeah. Someone on SO even said MSVC could link them.
 
i'm not in favor of that rule though. i actually like the book question. but i'm not going to violate the topic rules of the site
 
@sbi done
 
@rubenvb ohh
 
there are generally accepted good and bad books. The list is extensive enough to avoid debate
 
3:25 PM
it should be put into the c++ wiki IMO
 
Plus, it's a great reference for: "YOU DON'T KNOW SHIT ABOUT C++, READ A F-ING BOOK" answers.
 
as a cs student my book collection has exploded in a year
 
sbi
@JohannesSchaublitb Do you know anyone whose knowledge about C++ is above intermediate who disagrees with that list?
When was the last time this list has solicited "opinion, debate, arguments, polling, or extended discussion"?
 
@rubenvb why don't they generate real static .lib files?
 
@JohannesSchaublitb When in GCC world, do as GCC does.
 
3:26 PM
lol
 
I really hope Clang solves all this by superceding the cruft that is GCC/binutils.
 
sbi
@JohannesSchaublitb As had been discussed on meta, the tag wiki is a PITA to work with for substantial amounts of text.
 
There's still work being done on the LLVM native object file linker, so that's still in the pipeline.
 
at last i will need 4 votes on the topvoted answer to that question and i have GOLD xD
@rubenvb GNU LD could do so too
i guess this way with .a it is just simplier
 
3:28 PM
It can, but it also sucks.
 
@JohannesSchaublitb yeah, but that thing is sucky.
See? Instant agreement. The LLVM linker will be better, cause ... it will be better.
 
Joke's on you, I'm using Gold.
 
Yeah, Windows has no Gold
I hope the LLVM linker will make use of multiple threads.
That would be a win
 
GOLD is ELF only
 
hey guys
 
3:30 PM
Windows has no ELF.
 
My biggest peeve with Gold being that it can't do incremental linking with debug symbols IIRC. Real shame.
 
Xeo
@rubenvb IIRC, they mentioned on IRC that they would really like to.
 
@Xeo lol IIRC ... IRC
 
Note to self: never answer any questions where term "STL" comes up, otherwise pedants will start bickering about SGI STL, even though nobody cares about it.
2
 
Xeo
Where "pedants" = "Tomalak"?
 
3:34 PM
Strangely, no.
 
@DeadMG: Your starred message is stolen from me. I demand retribution!
Feb 28 at 10:16, by rubenvb
@anonymouslyanonymous oh so if the bakery is closed you go to the butcher's for bread?
 
heh heh heh
 
Where's ACTA when you need it. I would have SO chat closed down in an instant.
is there a rough timing function on Windows?
for cmd?
 
set system clock to 0, then request the clock when done
 
sbi
@CatPlusPlus In this case your criticism of others criticizing you is a bit unfair, though. The question explicit asked for the reason why something is the way it is. That's a question on history, and the commenters were simply pointing out that the history of the STL began before the standardization.
 
3:37 PM
There's timeit in the resource kit tools.
@sbi And I don't believe for a second OP meant SGI STL.
 
I also just found echo %time% which ought to do
I'm not downloading 12 MBs for something already doable.
 
Yeah, 'cause it's hours of downloading and then it takes 99% of your HDD.
 
sbi
@CatPlusPlus Maybe he did, maybe he didn't. Maybe he didn't even know such a thing existed. That doesn't matter, though. He asked why things are the way they are, and your answer fails, because things had been that way before the STL was incorporated into the standard (or the standardization consciously skipped over hash maps or whatever).
 
RB tree is an implementation detail. Standard requires map to be ordered. Hence why it uses RB tree. I don't see a problem.
 
we are learning about exceptions and templates after the test
 
sbi
3:41 PM
@CatPlusPlus And why does the standard require a map to be ordered?
 
because there is unordered_map
 
sbi
@JohannesSchaublitb There wasn't, though. (Also, we all know that the name is a dumb political compromise.)
 
28% of clang compile is done xD
there wasn't a litb
now there is
 
Eh, fine.
 
there wasn't an earth either
everything has a beginning
 
sbi
3:43 PM
@JohannesSchaublitb Yeah, and this guy asked exactly why it began the way it did. Why was map not designed as a hash map, and the standard later added a std::ordered_map? Not that I knew, but @Cat's answer fails to address the question.
 
why would ordering be worse than unordering?
i think it's a good thing
 
sbi
Who said it's bad?
Anyway, @jalf has now answered the question with a rehashing (doh!) of the history.
 
hows industry for programming? My professor told me that software engineers mostly sit in meetings and code once a week. I thought at first it was almost daily.
 
are std::function's convertible to C function pointers?
 
@rubenvb No.
 
Xeo
3:48 PM
no, how would they?
 
they go out of scope i believe
 
Xeo
std::function is polymorphic, function pointers aren't.
 
std::function can hold closures, function pointers can't point to closures.
 
Xeo
However, you can get a stored function pointer back through .target<T>
 
sbi
@LucDanton Don't they have a member function that returns a function pointer if they refer to a simple function?
 
3:49 PM
@sbi What Xeo said.
 
someone is having this problem: ideone.com/IgJjo
 
sbi
@LucDanton Yeah, I saw it, too, but he said it about three seconds before me, so...
 
And I am not familiar enough with this to help.
 
@sbi I didn't want to left you hanging if you ever missed that message! :)
 
Xeo
Man, my internet is so laggy again...
 
3:50 PM
@rubenvb Well, it's kinda obvious — they try to use C API as if it were C++ API.
 
@CatPlusPlus that was his idea yes. Any way to solve the immediate problem or is the design just impossible?
 
The C API appears to accept closures so the problem is fixable.
 
You'd need the standard void* user_data trick.
 
Xeo
@rubenvb If you have to deal with C API, you can't use anything but bare function pointers.
 
Then you can pass this along.
And have a free function dispatch to the member function.
 
Xeo
3:53 PM
std::function is completely out of the question, except if you have void* userdata.
 
Well, or create a thunk dynamically.
 
Xeo
Laggy internet really sucks in real-time chat.
 
unreal-time
 
Xeo
@CatPlusPlus Depending on when the callback will be called, that may not even be needed.
 
@CatPlusPlus +[] { return "Look ma, I'mma thunk!; }; this kind of thing?
 
3:55 PM
OK thanks. I suggested him to use a freestanding function to wrap it and pass this along.
 
Well, you'd need to capture this, dunno if lambda would convert then.
I was reading about Mono yesterday, and it automatically creates thunks for managed callbacks, that's why I thought about it. :P
 
c_api([](foo* this_) { return this_->member(); }, this); // lifetime management left as an exercise
 
wow, tls on osx is so slow compared to other platforms, at least when I build with gcc.
 
Xeo
@CatPlusPlus Only non-capturing lambdas convert
 
3:59 PM
only on noncapturing lambdas you can do +[]{}
the + is not allowed for the capturing ones
for the lulz
 
Mmmh, come to think of it if it's a true C API then isn't there the same problem of linkage as there is for static members?
 
Haha, nevermind me then.
 
I think it's unspecified?
 
Xeo
4:00 PM
I think so, the standard doesn't specify the linkage of the function pointer, as such it would be extern "C++", aka the default
And Clang IIRC implements it as a static member function
 
@LucDanton yes it is unspecified
a conforming implementation could fail on this code: void (*f)() = []{};
because it would only have a conversion function returning a C-linkage function pointer
 
In fact at this very moment I'm using lambdas with a C API. Let's check if it's compiled as C or C++.
 
Xeo
Man, LibreOffice sucks.
 
sensible implementations probably would have two "operator" for both clinkage and c++linkage
 
Xeo
@JohannesSchaublitb I somehow don't believe that.
 
4:03 PM
@Xeo read the spec and learn
 
0
A: Does std::vector::reserve reallocate the internal array?

Seth Carnegiereserve changes the internal size of the container (so that capacity() is now larger) but the size of the array doesn't grow any (size() remains the same as before the call). So, to directly answer your question, yes, it makes the capacity of the vector at least n where n is the parameter you gav...

Undefined behaviour?
 
sbi
in JavaScript, 1 hour ago, by Abhishek
looks like i just accidently made CSS tits
 
> "The closure type for a lambda-expression with no lambda-capture has a public non-virtual non-explicit const conversion function to pointer to function having the same parameter and return types as the closure type’s function call operator."
 
Accessing any uninitialised memory is UB, no?
 
4:05 PM
@CatPlusPlus assuming you write to it first
 
it doesn't specify the language linkage
 
If you write beyond vector's size(), you're breaking invariants.
 
For instance:
vector<int> v;
v.reserve(10);

*(&v[0]) = 0;
Yes it breaks invariants, but is it UB
I say no
 
It's a bug, who cares if it's UB or other kind of bug.
 
Why is it a bug if it's what you intend to do
 
4:06 PM
Well if by invariant we mean "invariant as specified by the Standard" then yes.
 
why wouldn't it be UB?
 
@jalf why would it?
 
I.e. can't use operator[] like that.
 
Because size() would report 0, and begin() would probably be equal to end().
 
@SethCarnegie because you're writing outside the vector
 
4:07 PM
@jalf Because int is trivial.
 
@SethCarnegie because it does not conform to vector's rules
 
A better example is v.data()[0] = 0;
 
@JohannesSchaublitb that doesn't make it UB
 
@SethCarnegie yes it does
 
@JohannesSchaublitb why?
 
4:07 PM
show us where in the standard it defines the behavior when you do this. If you can't, then it is UB ;)
that's what UB means
 
the vector does not say that v.data() points to allocated memory after a .reserve was done but no element was added AFAIK
 
If it's not mentioned, then it's unspecified behaviour, no?
 
if it did, then you could do vector<int> a; a.reserve(1); *a.data() = 0; without problems
 
@CatPlusPlus no, if it's not mentioned at all then it is undefined
 
@SethCarnegie yes, unspecified.
which means, that the impl can do whatever it wants because there is no restriction of behavior here.
 
4:09 PM
@JohannesSchaublitb Yes, an even better example should involve inserting something first.
 
so it could decide that unless you have pushed, it would return some nonsense from a[0]
 
I thought things have to be explicitly marked as undefined.
Anyway, don't do that.
 
@CatPlusPlus It's explicitly marked that whatever is not explicitly marked is UB.
 
It's a bug.
 
@CatPlusPlus then we have to define bug all over again :(
 
4:10 PM
@LucDanton Ah, fun in the standard world.
 
and the spec says that when any path even if not taken from unspecified behavior would result in undefined behavior, then the whole program's behavior is undefined for the program's input
 
@JohannesSchaublitb Much like the GCC and MSVC debug STL's will do. They'll trigger an assertion if you do it, afaik
 
@CatPlusPlus I looked that bit not too long ago tbh.
 
Where's my pizza, dammit.
 
@CatPlusPlus How else would it make sense? "Please write down everything that I mustn't do, and that'll define a language"?
 
4:11 PM
@SethCarnegie It's a bug, because it breaks vector invariants (size() increases after new element is inserted, for one).
@KerrekSB I don't know. I never viewed C++ standard as something making sense.
 
Ok, so it's UB by virtue of not being mentioned in the standard then?
 
@SethCarnegie unless you (or someone else) can find where it's mentioned, yes
 
v[0] is wrong and the specs for operator[] mention why.
 
even *v.data() = 0;
 
@LucDanton what if the vector contains one element
@KerrekSB I would think this is covered by pointer arithmetic
 
4:13 PM
You still can't access anything past size() - 1.
 
@SethCarnegie Then yeah accessing v[0] is fine.
 
Because it doesn't exist.
 
@LucDanton then by pointer arithmetic and the fact that adding an element can't trigger a reallocation and the fact that a vector's storage must be contiguous, it seems that you can do what I said just fine
 
There's space reserved for it, maybe, but it doesn't exist yet.
 
@JohannesSchaublitb Oh yeah.
 
4:13 PM
without UB
 
@SethCarnegie i don't think so
 
@CatPlusPlus how can it not trigger a reallocation but also not exist?
 
@SethCarnegie No you can't. Stop it already.
 
@SethCarnegie And where does it say that vector's operator[] is equivalent to pointer arithmetics?
 
Uninitialised objects don't exist.
 
4:14 PM
@SethCarnegie the implementation coudl rely on special OS system calls that guarantee contiguous storage upon special other function calls
 
It doesn't say, for example, that operator[] isn't allowed to do bounds checking
 
And size() says it doesn't exist.
 
@jalf I'm talking about pointer arithmetic like this: *(&v[0] + 3) = 0
 
say, the implemtation locks 5 pages for you. but to be able to write to the second page, it first needs to mark it writable
 
There's a reason allocator has separate members for allocation and initialisation.
 
4:15 PM
if you now think "ah a reserve is enough", it might not be because the other 4 pages are still read only
 
It's not the same thing.
 
@SethCarnegie Yeah, which relies on doing a [0], which, last I checked, was operator[]
 
Xeo
@Seth, that's kinda the point with UB. Just because you can do something defined UB doesn't mean you should. You can perfectly fine use the dreaded "union horrific cast" on most platforms, but that doesn't mean it won't blow up anywhere.
 
@jalf and we're assuming the vector has one element now
 
Allocation just pokes heap manager to give you free space. It's like renting a garage. It doesn't mean you automatically get a car.
 
4:16 PM
@jalf no. he assumes that "a" contains one element
 
@JohannesSchaublitb ah ok
 
@SethCarnegie what I said applies. you cannot assume that the memory after a[0] is writable
 
@Xeo I'm not saying whether it works even though it is UB, I'm trying to see why it's UB at all
 
@JohannesSchaublitb I like that example.
 
@JohannesSchaublitb that makes more sense then
 
4:16 PM
And you can't drive a car you don't have, no matter how many garages you have.
 
@CatPlusPlus what?
 
I'm just inventing clever analogies.
 
@SethCarnegie It's UB because the Standard doesn't promise you the code has a well-defined behaviour.
 
Don't mind me.
 
@CatPlusPlus what is your analogy analogous to?
 
4:17 PM
UB doesn't mean 'everything goes wrong'. It means 'we can't say anything about the resulting behaviour'.
 
@LucDanton yes I realise that, and I am trying to see if it is UB at all
 
Xeo
Also, IIRC, a conforming implementation might actually not reserve anything and just set an internal flag that it should reserve if you put anything else in
 
@LucDanton and apparently Johannes has showed that it is
@Xeo but then it would violate the requirement that push_back not reallocate, no?
 
@SethCarnegie Right but you're trying to see by not reading the Standard. That's silly.
 
@LucDanton I told you why I think it is not UB by omission
 
4:19 PM
Wot?
 
Xeo
I shouldn't make claims about the standard without having it open. :s
 
> then by pointer arithmetic and the fact that adding an element can't trigger a reallocation and the fact that a vector's storage must be contiguous, it seems that you can do what I said just fine
 
@Xeo Common mistake. I make it all the time.
 
@SethCarnegie I got carried away with allocations.
 
so you are on a street that just has been completed but there are still parts of it reserved for the military. you think you can take a shortcut to home and drive on the reserved military streets. until they say "ohh the enemy" and shoot you down
 
4:20 PM
@JohannesSchaublitb but the streets are reserved for you in this example
 
@SethCarnegie Ah well yeah. That's not reading the Standard. Still silly.
 
they are not reserved for you. they are reserved for .resize
i.e for the state. if they decide to move the military to other places they may open it up for you
 
@LucDanton how is that not reading the standard? It's taking parts from the standard and putting them together to make sense of something that is not mentioned but could be covered by a combo of other rules
 
Why are you so insistent on breaking vector?
 
@SethCarnegie no they're not. They're reserved here simply means "they exist"
 
4:21 PM
Here the Standard quote regarding contiguity of storage for std::vector:
 
as in, you do not have to wait for them to be built
they are reserved for you when you resize the vector to encompass them
 
> The elements of a vector are stored contiguously, meaning that if v is a vector<T, Allocator> where T is some type other than bool, then it obeys the identity &v[n] == &v[0] + n for all 0 <= n < v.size().
 
@jalf no, just when you add one element.
 
From 23.3.6.1/1.
 
@SethCarnegie adding one element resizes the vector.
 
4:22 PM
@LucDanton That settles it then
 
And that reserves that one element for you. You still have no guarantee about the rest of them
 
@jalf yes you do if you call reserve with a larger number than size() + 1
 
@SethCarnegie I really recommend diving into the Standard rather than speculating.
 
@LucDanton not speculating :)
 
@SethCarnegie what do you call it if not speculating?
 
4:23 PM
lol
 
@jalf reasoning?
anyway
 
Yeah, but C++ doesn't follow laws of reason or of nature. It follows the C++ Standard.
 
It would be reasoning if you based it on standard quotes: if you looked at what the standard said, and from that, tried to infer the behavior. You chose to bypass the standard entirely, and guess at how vector is defined, and that is speculation ;)
 
@jalf what is bypassing the standard about combining pointer arithmetic, vector guarantees (even if misremembred), etc?
 
well, or perhaps if you spelled out your assumptions clearly: assuming vector is defined in to provide this and that guarantee, then... That would work for me too ;)
 
4:24 PM
It's really counterintuitive tbh. Some things you get the feeling "it can't go wrong", but since the C++ Standard doesn't explicitly make it that way then a implementation is allowed to make it go wrong just to spite you.
 
@SethCarnegie the fact that you didn't look them up
 
@jalf I don't look up things I think I know
 
When you didn't look in the standard, how can that not be considered "bypassing the standard"?
@SethCarnegie That's fine, no one said you had to. Just that when you choose not to, then you are bypassing the standard
That's kind of what the word means
 
@jalf I don't consider "thinking you know what the standard says" bypassing the standard
I wasn't trying to reason outside the standard
 
@SethCarnegie well, that's fine. I don't consider birds to fly either.
 
4:26 PM
^
 
But if we go by the definition of "flight" and "bird" that everone else uses, then I'm wrong. If we go by the definition of "bypass" that everyone else uses, then you are wrong
you did not reference the standard. That means you skipped it, bypassed it, overlooked it, ignored it
 
What is the definition of bypass that you are using?
@jalf when did I not reference the standard?
I think this argument is not productive
 
By the way when I was speculating that data might be used for bypassing the contiguity requirement that's because I didn't know the specification of data: I thought I could use it to get a hold of, say, the memory that the allocator uses. Turns out though, it's specified expressively to forbid that. Which I had to lookup since I'm not one to speculate.
 
> to go around or avoid (a city, obstruction, problem, etc)
@SethCarnegie you're right, it isn't. :)
 
@jalf then we can quit arguing, with me thinking you are wrong and vice versa :)
And we can save a lot of time and move on to greater things
 
4:28 PM
@SethCarnegie We can quit arguing at any time, but you're still wrong if you maintain that you didn't speculate when you based your argument in speculation and refrained from looking up the facts
 
@jalf yes, we will quit arguing while you think I am wrong and I think you are wrong
 
anyway, I'm heading out for a bit. Have fun :)
 
@LucDanton I missed that part of the conversation; what did you look up?
 
The result of data only promises to be accessible up to data() + size().
 
4:33 PM
@LucDanton Yes, indeed.
 
Now to write a Hell++ allocator that marks the memory non-usable until construct is used!
 
@LucDanton Sounds like something a sufficiently advanced debug mode might want to supply.
 
Can anyone tell me if i = i++ is UB?
 
@PaulManta Yes.
 
Where's my shotgun?
 
4:42 PM
Def. UB in C++03 and I don't want to know for C++11.
 
Thanks!
 
("Yes" as in "Someone can tell you.")
 
does C++11 have constexpr std::string for construction from string literals?
as in, put data pointer to the const char* and be done with it?
 
There's no overloading possible on constexpr so that can't work.
 
@rubenvb No. You need dynamic allocation, and that can't be a constant expression.
Strings are mutable.
 
4:48 PM
For some reason.
 
@DeadMG "I don't want to know."
Why thank you.
 
Right. Dynamic allocation <> constexpr. They should've made a std::stack_allocator like Howard has for this use case in libc++
 
@CatPlusPlus Isn't the reason the age of C++? How many languages had 'clever' string handling that were not Perl or designed for text handling?
 
how long is the pointer returned by c_str guaranteed to last?
 
They had an opportunity to fix string.
@rubenvb As long as string itself is alive.
 
4:52 PM
@CatPlusPlus and unmodified I guess?
 
@CatPlusPlus What if you resize it?
 
@CatPlusPlus yes, as long as you don't call any mutators
 
@CatPlusPlus ?
 
@KerrekSB Yeah, that'd probably invalidate it, too. Dunno, I've never done that.
 
Guys let's not make assumptions, everyone please prepare Standard quotes for everything you say :)
 
4:53 PM
I just pass it to C APIs and they usually make their own copy.
@LucDanton I want immutable strings and real Unicode support. :(
 
@CatPlusPlus Can't say the first one ever had any real 'opportinity' to pass tbh :(
Would a range proposal that can deal with std::string be acceptable?
 
5:26 PM
@CatPlusPlus Roll your own?
seems to me that mutability/immutability is the kind of thing that you can solve on your own
 
immutable strings, with strings pool with reference counters is sorta complex thing
complex and maybe not usable in some cases
complex complicated? nvm
anyway const std::string is immutable enough
strings pool, which registers all existing strings, is memory-efficient, while you often use same string values
but there is a singleton smell
dunno, maybe there is another kind of immutable strings, without immutable_string str = global_strings_set.insert(".....");
 
5:52 PM
you'd really need a concurrent string set, of course
 
Meh, thread-local. Locking for string access would be silly.
 
what's the point of having a cache then? More like the sometimes-cache sometimes-pool
also, I believe that you can have lockless hash containers
 

« first day (505 days earlier)      last day (4425 days later) »