« first day (1411 days earlier)      last day (3530 days later) » 

5:00 AM
I mean, I can
but
sorta defeats the entire purpose
 
> an aggregate or union type that includes one of the aforementioned types among its elements or non-static data members (including, recursively, an element or non-static data member of a subaggregate or contained union),
Does struct aggr { double d; int i; }; include int as a non-static data member?
Then can I not access int actual_i; via aggr&? That’s daft!
 
@LucDanton Yes.
 
@JerryCoffin I wanted to do something like this.
lol it's funny how all this stuff compiles and works how I expect :(
it's taunting me
 
@LucDanton Umm...what? You seem to have things backwards: "If a program attempts to access the stored value of an object through a glvalue of other than one of the following types the behavior is undefined:" [emphasis added].
 
I’m fairly sure aggr is an aggregate, too :|
@JerryCoffin My point is that I’m following the bullet point to the letter here.
 
5:05 AM
every SO question I've stumbled upon said it's fine
I wish it was
 
It’s a classic, too. I’m sure we’ve broached the topic here before.
 
How come GCC doesn't warn?
They have a strict aliasing warning
 
@LucDanton The point is that since you're following one of the bullet points, it's allowed.
 
aggr is an aggregate that includes the dynamic type int among its elements/non-static data member, no?
 
@LucDanton but I don't think that bullet means what you're saying it means
 
5:07 AM
Someone should post this question to SO.
 
@JerryCoffin What’s the net result? What do I end up reading?
 
Sure, it does. That means the paragraph saying that it is not allowed does not apply to this situation.
 
@Rapptz I’ll try to mix it up to make it complain.
 
That's not the same thing as saying this situation is allowed
 
@LucDanton As long as the access is via one of the types listed in the bullet points, the result is defined. Since you're following one of the bullet points, you get defined behavior.
 
5:09 AM
See, I thought the aggregate bullet was for struct aggr { int i; double d; };. Now I’m not sure what this is allowing.
> error: dereferencing type-punned pointer might break strict-aliasing rules [-Werror=strict-aliasing]
^GCC no like
@Rapptz This produces a warning for me. It doesn’t show it on the link because I don’t know how to use that online compiler :<
@JerryCoffin See, I’m surprised not because it is defined, but because it is defined and senseless. How do I connect the aggr value to the actual int?
 
@LucDanton No warning for me.
GCC 4.9
and Clang 3.4
 
k, maybe it’s being conservative—feed it -Wstrict-aliasing=1.
 
I see it now.
 
This isn’t the default due to the risk of false positives.
I suppose it even warns about the original snippet now…
 
But I'm using pointers, not references
 
5:18 AM
@LucDanton Typically by something like reading a network packet into an array of char, looking at enough to verify the packet type, then using a pointer to the correct type to read the members. But it's up to you to account for anything like padding between members, so while that can give defined results, it's next to impossible to guarantee it in code that's even close to portable.
 
I'm not sure they're the same w.r.t. rules though.
 
user1646075
.......... orrrrrrrrrrrrrrr - he could say SDL_thingy(my_wrapper.SDL_lump) - and the discussion is moot
 
I won't do that
or the UB thing
 
@Rapptz The rules mention neither pointers nor reference. Only glvalues and types.
 
Luc: long long x; struct XA { long y; long z; }; long long r = static_cast<long long>((XA*)(&x)->y)<<(CHAR_BITS*sizeof(long))|((XA*)(&z)); ...
That's UB
y and z are accessing the stored value of x other than by one of the bulleted items
 
5:20 AM
@aclarke In order for me to do that, I'd have to double the size of the class.
I don't want to do superfluous get_x, get_y et al.
 
That's my reading anywho
 
@HWalters That’s not really readable.
Aug 23 at 16:39, by Feeds
PUBLIC SERVICE ANNOUNCEMENT: READ THE RULES.
 
user1646075
@Rapptz ok, i hear ya on that one.
 
Markdown may be eating up the *’s.
 
is Coliru down
yup..
 
5:22 AM
@Rapptz Looked like it to me, hence the unusual compiler.
 
I want the original code to copy paste
see if I could fuck it up some more
meh
 
@JerryCoffin I find it uncharacteristic of the Standard to leave things semi-defined like this. Esp. when it involves aggregates. Oh well.
@JerryCoffin Also the scenario you outlined is defined by virtue of trivial copyability (admittedly by using the ‘allow trivial types out of thin char’ interpretation).
 
@LucDanton Basically, my reading isn't that this is telling you that, if you have a structure, and it has a member with the right type in it, you can use that to access an object of that type...
 
@Rapptz Given your original intent, I'd probably cheat and use inheritance:
struct c_api {
    int x;
    int y;
    int z;
};

int do_calculation(struct c_api* stuff) {
    return stuff->x + 10;
}

struct fancy : public c_api {
    int do_calculation() {
        // delegate over to C API land
        return ::do_calculation(this);
    }
};
Simple, straightforward, clearly defined.
 
...rather, it's saying that if you use a structure to access the storage through that type other than by the specified bullets, it's UB; if you simply cast using a structure, you might not be accessing the storage at all, in which case it doesn't apply anyway
 
5:26 AM
@HWalters If I have a struct object it goes without saying that I can use one if its members, yes. You don’t need an additional aliasing rules for that, accessing subobjects is clear enough.
 
@JerryCoffin Well. Yeah. You're right.
I was really stuck on the whole C mindset I forgot about inheritance.
 
@HWalters And have you noticed the crazy bullet that involves aggregates?
26 mins ago, by Luc Danton
> an aggregate or union type that includes one of the aforementioned types among its elements or non-static data members (including, recursively, an element or non-static data member of a subaggregate or contained union),
That’s the one.
 
Yes. int y; struct X { double z; int q; }; As I understand you're bringing up (*X)(&y)->q
That doesn't access the storage of y. So, the prerequisite for the big thing before all of the bullets isn't met in the first place.
 
Which is not sane. How does the restriction to having a member of appropriate type help in any way?
@HWalters We’re absolutely assuming that ‘the program [is attempting] to access the stored value […]’, why else would we bring up those rules?
 
long long y; struct X { long a; long b; }; (*X)->a accesses the storage of y through X.
 
5:30 AM
Ah, but storage is not a (direct) prerequisite for those rules. Why are you mentioning it?
Allow me to clarify.
 
user1646075
@HWalters say whay?
 
"If a program attempts to access the stored value of an object through"...
 
@HWalters No, this is not just about ->q. This is about using the resulting X value, any which way.
 
@LucDanton I think I see the problem. I think you're reading it as: "an (aggregate or union type) (that includes one of the aforementioned types among its elements or nonstatic data members ...)", but I believe the correct interpretation is: "an (aggregate) or (union type that includes one of the aforementioned types among its elements or nonstatic data members)."
 
That's what the bullets go under
 
5:32 AM
@JerryCoffin Yup. With the latter interpretation though, are we allowing it any aggregate?
 
@JerryCoffin A union doesn't have data members though.
 
@Rapptz Sure it does. union x { int a; double b; }; has members a and b of type int and double respectively.
 
Those are called 'data members' by the spec?
TIL I guess.
 
I’ve avoided saying the obvious (as per usual) but it’s been counter-productive tonight so: unions are a subset of classes.
 
@Rapptz I'd have to check--those might be elements, and a data member would only happen if you had a union of (for example) a couple of structs that had data members.
 
5:34 AM
@LucDanton I know that. However I didn't know they used the same wording because they weren't very 'class-like' until C++11.
 
But ultimately, yes: the standard uses pretty much the same language to refer to classes, structs, and unions.
 
49 mins ago, by Rapptz
> Two standard-layout union (Clause 9) types are layout-compatible if they have the same number of nonstatic data members and corresponding non-static data members (in any order) have layout-compatible types (3.9).
§17 from earlier. Unions do have data members.
 
heh
Yeah.
See starboard.
 
Eh, I can’t fault you for going over this carefully. I did ask myself the same.
Notably I found that ‘elements or NSDM’ thingy somewhat flipped, with respects to ‘aggregate or union’. Reversing it doesn’t really help though.
 
@LucDanton Yeah--rereading it, I'm not sure there's a way to interpret it so it really makes sense. At the very least it needs clarification, because at least two readings are equally valid (and I think "equally valid" in this case means "neither reading reflects what could possibly have been the real intent").
 
5:39 AM
Inheritance does solve my whole problem though.
 
@Rapptz ...and eliminates the cast! :-)
 
I got too caught up in the whole 'is it UB or not' discussion to see the solution blindly in my face :v
I wonder what's a good way to do 'manual' documentation.
I wanna try it for fun.
I say 'fun' in the loosest sense btw
 
@Rapptz Chalk one up for "pair programming" (using the term so loosely that it's nearly meaningless, but that doesn't seem any different from how everybody else uses it).
 
ThePhD and I did something similar to pair programming a while ago.
 
@JerryCoffin For funsies I’ve been tracking ‘elements’. So far it appears the term is only ever employed for arrays, initializer-lists and initializer lists, packs and more syntax for the language part. It appears in the library part as expected (containers, algorithms etc., but also ‘elements of the library’).
Point being, I don’t see it being used elsewhere for class types. It’s crazy.
Closest thing is when the library requirements describe the bitmask-like types, there’s a ‘list of enumerated elements’.
Ah, tuple elements of course.
 
5:48 AM
@LucDanton I'd say it' s more like a fairly typical result of a huge document written in only semi-formal language.
 
Agreed. My shock stems from my opinion of the aliasing rules, which I thought were a cornerstone of the memory model as well as the type system.
 
More formal language can remove a lot of ambiguity, but at severe expense in readability (cf., Algol 68).
 
I’m not going to touch that.
Codecvt have source and destination elements. It’s more array stuff though really.
‘Format elements’ for std::time_put.
 
@EtiennedeMartel Well, I am surprised that they did not kill the reporters as well for coming from infidel country.
 
@LucDanton It's worth reading sometime, if only because nearly everything since uses (and abuses) terminology it invented. Reading it is an utter pain though (and the original Algol 68 standard was even worse). I spent most of one summer studying it carefully, and at the end of that summer I'd have said it was the clearest, most unambiguous standard I'd ever written. I think it probably still is, but it takes a couple of months of close study to get past its formality.
 
5:55 AM
@JerryCoffin What made you exert so much effort?
 
user1646075
@JerryCoffin I spent some time as a callow youth reading the "Informal Introduction to Algol 68" (red book) and it was mind-blowing. That's out there somewhere freely available now.
 
@VáclavZeman Depression? Masochism? Simple insanity? I don't really have a good answer I guess.
 
@JerryCoffin :D
 
user1646075
'cos it's epic and .... canonical?
 
5:58 AM
@EtiennedeMartel Man, just watching that raises some fear in me. :( This is fucked up.
 
Yup, no elements for classes outside of that one slip. It does make sense I suppose.
 
@aclarke Actually, that's probably a pretty fair part of it. In the '80s (or so) nearly every argument over languages (of which there were many) ended up referring back to Algol 68 as the fundamental source about language design (at least for languages in the...Algol family). There were enough disagreements over what even simple terms meant, that getting solid data directly from the source was interesting, to say the least (and brought more than one argument to a screeching halt).
 
user1646075
@VáclavZeman I hate the apologists - "I would be killed too" or "I'm not like that" "so stop complaining about (my religion)"
 
@LucDanton Should be put together a formal defect report?
 
user1646075
@JerryCoffin also the bragging rights
 
6:02 AM
@JerryCoffin Eh, I’m too tired to make that kind of decision right now. I’m still up because I’m waiting for the shops to open—I’ve run out of food.
 
@aclarke Oh no, I'm far too humble for that to matter at all! :-)
 
user1646075
all the 'ref ref' stuff blew me away. I never did quite get clear exactly what data objects actually existed at runtime to support it all. But then, I was a callow youth... new to all this business.
 
@LucDanton It's, what, 0800 now?
 
Yup.
 
@LucDanton Shouldn't bakeries be open already?
 
6:04 AM
Ya, but I’m waiting for the supermarket.
 
@LucDanton Oh, Okay.
 
user1646075
@LucDanton they're not 24 hours in your zone?
 
Gotta have something to put on the bread! I have no more butter.
 
Speaking of the time though, I should probably go get some sleep. Later, all.
 
@aclarke Not the ones within walking distance. Even then it’s very likely not the case, no.
 
user1646075
6:07 AM
ciao for niao. nearly /normal working hours/ home-time for me too ;-)
 
the sun is shining & yet it's raining at the same time
 
Good morning, everyone.
 
and my tummy is still not right - thanks to the food poisoning last night :(
 
I have a brief question (which doesn't really belong to the main site, which is why I came here), if you don't mind?
 
all questions belong to the main site
 
6:10 AM
I'll just ask: Which would you consider 'better' in a polymorphic environment. An overloaded callback function to get a specific value or a variable, which can be set in each constructor?
That's an opinionated question and that's why it doesn't really belong to the main site, does it?
 
all answers on the main sites are just opinions, some opinions are more popular than the others
 
Well, the answers I tend to be around are more about the facts, but yeah, programming is about opinions and personal tastes as well. However, if I recall, there is actually a closing criteria called 'opinion based'.
 
close votes are opinion based too
 
user1646075
under what circumstances will the value be different per class or object?
 
That they are.
A little background info: It's a display system. There is a master class, which gets specialized down into a really large tree up to the actual display. Some of the templates require additional info like 'Which symbol to use'.
 
user1646075
6:14 AM
sounds like Win32's Window classs..
 
@ATaylor I think that depends a lot on what you want to do with the value - is it private or public for example
 
The question is: Is it better to keep a protected instance of the type that symbol is made of in the template class that requires it or is it better to declare an abstract method which is to return it.
Generally protected, chmod.
So yeah, for the outside world: private.
 
user1646075
so, at sporadic points down the inheritance tree, a class and then further descendants now get a different value?
 
Yup.
 
user1646075
if you already have virtuals (ie a VT exists) and if you don't access this magical value that often, seems like an instance variable is probably a bit over the top
 
user1646075
6:16 AM
ie a virtual function seems groovy, and also would prevent an idiot on your team from trying to assign to it. - unless that MIGHT be useful?
 
@ATaylor The two options are different enough so as to be unrelatable.
 
As it stands now, I'm the only idiot at work with this. Another 'problem' would be explaining how to change the symbol for a specific menu to others.
And yes, I do have virtuals. A lot of them actually. So, in your opinion, I should roll with the overloaded function instead of the protected variable. Is that correct?
And that 'magical value' will only be accessed each time the menu is completely rebuilt (which happens only on specific user interaction, which seems rare enough)
Well, I think I can work with that. I thank you very much for your time :)
 
user1646075
that's my casual take, 'just cos it'll save a bit of space in each object. Burn some space only if it'll save good cycles is my general approach
 
I see, yes. Makes perfect sense. I'll be going back to work now. So yeah, thank you and have a good day to come. :)
 
user1646075
enjoy!
 
user1646075
6:23 AM
also, i recall situations where not having a more abstract accessor for a fact (even a simple one) suddenly interferes with new complexity, and then I groan and start the refactoring...
 
0
Q: Lambda VS Function

LeviI just finished learning about lambda expressions and was wondering whether an expression or a regular function would execute faster when printing to a console using cout. Should I use // Lambda expression auto helloWorld = []() { cout << "Hello World" << endl; }; or // Normal function v...

I'm amazed.
 
user1646075
do we care when IO is involved?
 
user1646075
... assuming he'd be interested in /eventually/ passing some goddamned args to it even
 
user1646075
think i'll take pity and say something
 
no need for that
usually a scathing comment is sufficient
 
user1646075
6:37 AM
heh. but i need more points so i can see deleted threads (referring to earlier chattery here)
 
you forgot "imaginary internet"
 
hiya
i needz suggestion on if I should calculate post ranking on the fly or cache its result
or possibly give me some resources because today google is not my friend
 
no.
 
motherfucker
bye
 
lol
 
user1646075
6:42 AM
was that a 'please help me with my homework' ?
 
@aclarke no I needed suggestion if I should calculate ranking on the fly or cache its result
not the implementation to do so
don't boost your ego with such bullshit
now bye for real lol
 
user1646075
the 'rude' response is because this chat room is for chatting, not for Q and A in general. Your question is also highly dependent on the cost of not caching vs. the benefit
 
this is not a forum.
 
user1646075
picky picky
 
@MarkGarcia the accepted answer wrong in the general case
 
user1646075
6:48 AM
hmmm - the name sounds middle eastern, but the flag screams gay pride.
 
I'm not sure how that's mutually exclusive.
 
user1646075
not necessarily, but culturally there's a much stronger repressive factor at work.
 
user1646075
some of my best gay friends are middle eastern - wait what?
 
@quantdev It doesn't use cout. :P Seriously though, the OP's question doesn't really call for something that would be useful.
So it doesn't matter how it is answered.
 
The newblet came and gone like the wind out of a weasel's backside
 
6:55 AM
@aclarke ok sorry I was very angry searching for this since (last night -1) but I found a way myself. best of both worlds
I lied when I said bye :)
anyway I'm not gay but I got this avatar automatically upon joining chat
 
Sounds like a bug.
 
user1646075
better change that quick then!
 
Make a question on Meta Stack Overflow
 
maybe its of help that I'm behind a proxy?
@aclarke I did but still waiting for change
 
You guys will laugh at this
 
6:57 AM
as you can see from my main site profile
 
I'm tired... I'm tired and nervous because this is a new job I just learned promises... I don't want them to fire me but their going to fire me. I'm all the way in Tokyo so I'll be stranded and homeless 1000's of miles away from home if I'm fired. Thank you very much and I apologize — grasshopper 5 hours ago
 
user1646075
i think the idea is that all newbs are automatically assumed to be gay
 
haha it may be
@BenjaminGruenbaum I don't laugh very much cause I understand the frustration of this guy becoming almost comical. I mean frustration makes you crazy and hilarious
 
if you got the avatar as the default, you must be using it as your profile picture somewhere else
 
user1646075
... think i need an avatar. Wooldor Sockbat seems like a good choice
 
user1646075
7:08 AM
hmmm - the one f*cking the toaster, or a portrait? want to find one where he's going 'weeeeeee'
 
wait 'm gon' change da avatar nd see if it changes up chat room
 
Wooldor Sockbat?
isn't that that guy from Drawn Together?
 
Yes.
 
user1646075
yup - i want one where he's going 'weeee' - if he doesn't occasionally throw his arms back and run across the room screeming 'weeeee' he will die
 
user1646075
changed it in my SO profile - when will it come across here?
 
user1646075
7:14 AM
is that the place to set it for chats?
 
user1646075
anyway, home time. peace out bitches
 
> The C++ domain currently does not support template classes/functions/aliases/variables (e.g., template<typename T> MyClass), only template instantiations (e.g., MyClass<T>).
amazing
 
Source?
 
7:26 AM
> CppDepend can be used to explore all code elements and dependencies, CppDepend provides CQL langage like SQL to query the code base , and also nice graphs to understand the code:
user image
6
lmao
 
lololololol
 
this answer is deleted on SO
it actually has an upvote.
Oh wait, it doesn't.
 
@Rapptz I want to cry.
 
morning all
 
Good morning!
 
7:28 AM
I want to go home already
 
@TonyTheLion You're a lion.
 
Hm..
Sphinx doesn't support enums.
Impressive.
 
@TonyTheLion I was off work ill on monday, that was as fairly good morning.
@Rapptz global constants, global constants everywhere!
 
@thecoshman heh, it was a bank holiday here monday
 
7:36 AM
@TonyTheLion oh, good for you :P
hint: we have different bank holidays here
 
I figured as much
 
7:54 AM
@thecoshman macros!
 
@PolymorphicPotato polos
 
making that ASCII table was such a pain
even with ascii-flow
:<
 
# Painless ASCII table:
for i in range(128):
    print("{0}: {1}", i, chr(i))
 
@Rapptz why... why would you do that?
 
8:03 AM
idk
 
Fool of a Took
 
This question appears to be off-topic because Stack Overflow is not a code translation service. — Rapptz 16 secs ago
@PolymorphicPotato lol
someone flagged that comment and it got deleted
 
note to self
don't start Haskell game jams when drunk
 
8:25 AM
@BartekBanachewicz lol, why? Was it a disaster?
 
@BartekBanachewicz The bottom one is nice! :)
 
I can't take credit for that, unfortunately it's not my commit :P
well it was fun but we ended up far from a playable game
 
@Rapptz I wonder what video was that for.
 
8:33 AM
@Rapptz Thank you!
 
oh, TIL
 
Hm?
 
when vim tries to create a swap file, it uses .<filename>.swp. If that already exists, it uses .swo, and then .swn, etc, until it gets to .saa
then it gives up
 
oh
I surprisingly knew that. I learned about it in this room.
 
ah
 
8:44 AM
@LightnessRacesinOrbit Well, it is kinda true, is it not?
 
This is heaven.
<google-map class="pinn-address-form-map" fitToMarkers>
    <google-map-marker latitude="48.85837" longitude="2.294481"></google-map-marker>
</google-map>
 
9:24 AM
Visual Studio 14 CTP3, huh? I wonder if it supports side-by-side install with other versions.
 
I think all VS versions support side by side installations
 
@AlexM. All final, non-CTP versions, you mean? :)
 
why would that change anything? IIRC CTP is like a beta
 
the original VS 14 CTP did not support side-by-side installs.
dunno if CTP2 or CTP3 changed that
 
huh that sounds weird
 
9:30 AM
@AlexM. because Microsoft's idea of beta can be summarized as "fuck you"?
Or because MSI is such a piece of shit that even the MS DevDiv struggles to write installers that just.. install, without blowing up your system
 
Woot.
A WYSIWYG editor library that doesn't have its own stylesheets.
Damn awesome.
 
or because VS sticks its greasy little fingers into so many system-wide pieces of configuration that making it install side by side is not something that happens by default, but rather is a major engineering project on par with the Moon landings in complexity
I can think of lots of reasons why it doesn't work
 
lol
the third option is probably the most legit
 
I'm pretty sure the second one is also relevant
 
 
9:34 AM
@Feeds All hail the God-Empress
 
When's the What If...? book coming out?
 
@R.MartinhoFernandes scammed
(not jelly at all)
 
Xeo
@R.MartinhoFernandes Soon­™
> It will be available starting September 2, 2014.
 
   int foo = 1;
   long* ptr = (long*)&foo;
Is this UB?
 
9:51 AM
I don't think so
 
Without the explicit cast, the compiler complains
 
oh
 
main.cpp:22:17: error: cannot convert 'int*' to 'long int*' in initialization
long* ptr = &foo;
 
Xeo
@TonyTheLion As soon as you access *ptr you violate strict aliasing
 
@TonyTheLion huh...
@Xeo but we are not accessing it yet.
 
Xeo
9:52 AM
Which is why I said "as soon as"
For now, it's fine
 
@TonyTheLion for some reason that makes sense to me
 
Xeo
it's a reinterpret_cast under the hood
 
ok, just so we are on the same water born vessel
 
Xeo
and if you cast it back before accessing, you're fine too
 
@Xeo ah right, I knew there was some catch to this
in the code I'm looking at it passes (long*)&foo as a param to a function I can't see the guts of
I just hope that the function does the right thing then
 
9:59 AM
it almost certainly won't
 

« first day (1411 days earlier)      last day (3530 days later) »