« first day (639 days earlier)      last day (4308 days later) » 

2:00 AM
today is fifth season premiere of Leverage
and if I was a good boy I'd have to wait about 1billion years to watch it
 
Ah. It's a show.
 
but thanks to torrents, I am downloading right now.
 
The puppy is not a good boy?
 
I mostly torrent TV shows, and almost exclusively those which are not currently available in this country.
 
There are so many shows I would pay to watch, but unfortunately they are not "available in my country". So I download them. Fuck 'em, they lost a sale.
 
2:02 AM
agree
 
Will this create an empty vector, or will it create a vector copying [i, i+4)?
`std::vector<char>(i, std::advance(i, 4));`
std::vector<char>(i, std::advance(i, 4));
 
Order pizza. (i.e., it's undefined behaviour)
std::advance modifies i.
Use std::next if available.
 
oh sweet, std::next is what I've always wanted!
its like christmas all over again!
I really need to brush up on the new features in C++11
 
Xeo
@RMartinhoFernandes Oh, that's some sweet UB.
As long as it isn't Hawaii style, that is...
 
@Xeo Sweet pizzas are cool.
 
2:08 AM
this is in a for loop so I'm using std::advance(i, 4) anyways... but UB, good to know
 
There's a restaurant nearby where you can pay 9€ and eat as much pizza as you can. And it includes dessert: pizza!
 
technically its not undefined behavior, but it might be if that was i++. std::advance doesn't return anything. I didn't realize that until just now.
 
$ mono ucd2c++.exe ucd.nounihan.flat.xml src/ucd
Killed
$
WTF? Can't I get a decent error message?
 
Your problem is Mono.
 
It works on my machine :S
 
Xeo
2:12 AM
@RMartinhoFernandes Omg
Do want.
I'd probably storm the shop ever 3rd day with friends
 
Xeo
Or is it "per person"?
 
Per person.
Duh.
 
Xeo
A man can have dreams!
But without that... meh. A normal pizza for 4€ is enough to fill me up
 
Xeo
2:15 AM
Must be nice for robots, though, if you got a biochemical energy converter from pizza
And "per person", not "per robot", so bring 1 person and fuel yourself forever
 
Hey! Robots are people too!
 
Xeo
@RMartinhoFernandes Yeah... no. :P
 
In that case, if I go alone I could just bankrupt them.
 
Xeo
4
Q: Default destructor nothrow

icandoThe following code doesn't compile under gcc-4.7.1 but compile under clang-3.2. Which one follows the C++11 standard? struct X { virtual ~X() = default; }; struct Y : X { virtual ~Y() = default; }; gcc-4.7.1 complains that: looser throw specifier for 'virtual Y::~Y()' error: overriding ...

GCC bug?
 
2:20 AM
Ah fuck this. I'm going to generate the things on my machine and scp them to the build server. It's not like the UCD will change often :S
1
Q: C++ ensuring a float size of 4 bytes

Di-0xideI need a cross-architecture way to ensure that a float will be 4 bytes (as is on 32-bit windows). For instance, in the structs I'm creating, I'm using __int32 instead of int to ensure an integer value that is 4 bytes long. How could I do this with a float? I know that I can just substitute the v...

This guy is annoying.
And in the end, all he wants is...
@Robᵩ - Just need to ensure that when compiling on 64bit after designing a struct that uses float on 32bit, the struct size stays the same. — Di-0xide 23 secs ago
 
2
A: C++ ensuring a float size of 4 bytes

Robᵩ I need a cross-architecture way to ensure that a float will be 4 bytes There is no analog to int32_t for floating-point values. The only cross-platform way to achieve what you want is to test for it with either runtime or static asserts. #include <cassert> int main () { assert(s...

Love how this triggered a "too many comments" flag in just 9 minutes...
 
@Mysticial Turns how his "cross-architecture" requirement was merely "works on x86 and x86_64".
Also, it's "foolproof".
 
lol
 
Writing "fullproof" makes you look like a fool :P
 
@Robᵩ - I'm packing the float to 1 byte alignment (I believe is the correct way to say that..) using #pragma pack (which I'm sure isn't cross-platform compatible, but for now it works until it reaches that point). Endianness will be taken care of if the need arises; however, knowing the client is guaranteed to be running on windows in 32-bits and the server will be running either on win32/64 or (hopefully) debian 32/64, I think it'll be fine. — Di-0xide 30 secs ago
Facepalm...
He's doing that and he's worried about standards compliance...
 
2:36 AM
Packing to 1-byte alignment. lol
 
That's not packing.
 
One more comment and the question will also trigger a "too many comments" flag.
lol
 
@Mysticial i just think he's an idiot, and i refuse to help idiots
@Mysticial it's kind of like trying to answer a kid, who keeps asking "but why"
 
My cousin does that. I like him.
 
good evening all :)
 
2:41 AM
@RMartinhoFernandes yes, but when the answer is an IEEE standard...repeated over and over again , when that standard pertains to a particular hardware floating point unit ... ya know.. they guy asking the question has no idea about floating point to begin with... and as such thats what sparked his question, when in reality i doubt seriously he's got a compiler for any hardware that dosent have a floating point unit to begin with
@RMartinhoFernandes like, seriously, he should worry more about NaN than float data size
@ITNinja evening sir.
 
what type of a spider is that
 
The Brazilian wandering spider. Most venomous spider in the world.
 
Oh gawd, bugs.
^ Debugger.
 
why cant browsers just accept one way of doing things instead of making effects in css different in different browsers?
(specifically IE)
 
2:50 AM
Because CSS was made so as to allow different implementations?
 
@RMartinhoFernandes A millipede was chilling on my wall the other day. I let him be.
 
its just.... stressful.... xD
 
Night all :)
 
hehe
 
2:54 AM
night :)
 
@ITNinja the answer to that is simple, MS did not come up with css... so theay fail to implement it properly
@ITNinja one could arguably say that also about their c++ compiler
@ITNinja of course, to note , IE has never displayed web pages properly... sense the dawn of IE .... it's always had issues with pages, and truly at one point in time you had to have one page for IE users, and another for "everyone else"
 
There's something about big companies with lots of big egos competing to define functionality they shouldn't… and the biggest ego wins
 
i still laugh when i see the IE9 advertisements haha
 
well look, in all fairness ms is the largest software company in like.. the universe
their real issue stems from the fact that theirs very very few pieces of software that has MS's branding that was an original MS product
 
@johnathon Nah, that's the Sirius Cybernetics Corporation.
 
3:00 AM
lol
@RMartinhoFernandes Chandler Carruth thinks it's google :P
 
Hmm, GCC's first phase lookup is borked.
 
Google also acquired most of their products rather than developing them in-house. And MS's worst offenders, IE and Office, are mostly in-house from scratch.
 
I heard they IE9 was a rewrite.
 
It's always a rewrite… atop a compatibility layer to support emulating the old version
If Microsoft can do anything, they can say the right thing to PHBs. And "it's a rewrite" is perennially the best marketing.
 
3:20 AM
man
watching a program about how basically utterly shitless our government was who kindly bent over our whole population to line the pockets of our food industry
and the presenter is asking the official and she's just instantly so shifty
she's just like "I don't agree with terms like "obesity crisis""
the fuck, woman
 
@DeadMG That's what you guys elected her for, right?
 
lol
 
3:33 AM
I should get to sleep. But I don't want to.
 
Fat people who want their freedom have a legitimate claim… and they should have to sign health care waivers.
 
In computer security, a billion laughs attack is a type of denial-of-service (DoS) attack which is aimed at parsers of XML documents. It's also referred to as an XML bomb or as an exponential entity expansion attack. The example attack consists of defining 10 entities, each defined as consisting of 10 of the previous entity, with the document consisting of a single instance of the largest entity, which expands to 1 billion copies of the first entity. In the most frequently cited example, the first entity is the string "lol", hence the name "billion laughs". The amount of memory used would l...
 
"I understand that fizzy drinks will kill me and I won't ask for help."
 
@RMartinhoFernandes lololololo
(Don't ask me what's the reason)
 
3:48 AM
i would so let my student off if they did this haha.
 
@johnathon I have to disagree. Many Microsoft products (especially the biggest ones like Windows and Office) were developed primarily by Microsoft. The question of where their products were developed pales in comparison to one simple problem though: Steve Ballmer is pretty much the worst CEO in the history of mankind.
 
@JerryCoffin Pick any CEO of Hewlett-Packard
 
@ITNinja When I was in fifth grade my teacher told me I had to write "I will not talk in class" 50 times (or something like that). I turned in a paper with one sentence: "I will not talk in class 50 times." My teacher was pissed, and threatened to do horrible things, but my dad intervened. He pointed out that I'd done exactly what I was asked. If she wanted something else, that was her problem.
 
Better than writing "I will not", once, and then talking in class 50 times
 
@Potatoswatter HP's worst still isn't even in the same league with Ballmer. Granted, they've been pretty lousy, but if you combined the worst traits of each you'd still end up with somebody much better than Ballmer.
 
3:53 AM
Ballmer is a singularity of bad CEOness.
 
@RMartinhoFernandes Somehow I don't think that's the singularity Vinge and such have in mind, but hard to argue anyway.
 
@Potatoswatter My physics teacher in high school was much better. He was asking about what would happen when sound waves crossed. Somebody quickly said they'd cancel out. His comeback was something to the effect of "so you can't hear either Jerry or me right now?"
 
4:15 AM
when deleting a c++ object, which destructor gets called first? the deleted class' destructor or it's member's destructors?
say I have class A { private: B _b; } a;
and I say: delete a;
?
is it A's or B's?
 
@KarimA The members are destroyed after the body of the owning class' destructor.
 
Do I have any guarantee that by the time my destructor is called, all member values are not unloaded yet?
 
Yes. When the body of your destructor executes, the members are still available. After you say return;, they get destroyed.
 
Xeo
0
Q: The Boost library, serialization, and an ampersand operator?

UriI come from a Java and C# background and as a way to dive into C++, I'm building an icons dock using Qt and Boost. Looking at the documentation for the serialization, I stumbled uppon some interesting use of an & operator. class gps_position { private: friend class boost::serialization:...

 
It's the only sensible way…
 
Xeo
4:20 AM
The joy of operator overload abuse.
 
Potatoswatter - thanks!
 
At least it's not the unary &
 
Got around to previewing more shows this season...
 
another question: is there any time limit that I have in a destructor before the OS forcibly terminates its memory?
 
Tari Tari = Hanasaku Iroha season 2 - quite literally...
 
4:21 AM
I'm not asking about the case when a process is unloaded.
just purely about delete x; scearios
 
@KarimA That depends entirely on the OS and how it's configured.
 
@Xeo, did you watch Hanasaku?
 
Xeo
@Mysticial The first episode, but I couldn't muster the interest to follow it further
 
If the OS isn't trying to terminate you, it has no idea that you're destroying anything.
 
@Xeo The show is definitely kinda slow...
 
4:23 AM
because I have a class that internally has a producer/consumer on two thread and in the destructor I want to signal the consumer thread and tell it that it is free to go home, and I hold a mutex & a conditional variable that the consumer thread signals when it acknowledged that it's indeed going home. Is this bad design?
on two threads*
 
Xeo
I don't think I'll watch anything this season, really.
Only if it turns out to be super-interesting after all
 
@KarimA Sounds good to me. Did you just work that all out for yourself or did you follow a recipe?
 
myself
 
Good for you!
 
@Xeo :(
 
Xeo
4:24 AM
Or maybe Muv-Luv Alternative: Total Eclipse, since I'm currently playing the original Visual Novel which is the only one with a score of over 9 on vndb
 
I mean - this is the most obvious way
 
Xeo
But that thing has an estimated playtime of roughly 60h
so I don't think I'll have much time in the next few days
 
@KarimA For many folks the most obvious way always involves sleep ;v)
 
sleep() is not deterministic in this case :)
 
That's the magic word!
 
4:25 AM
you have no guarantee that it indeed cleaned up its state.
 
Xeo
4:37 AM
0
A: The Boost library, serialization, and an ampersand operator?

perrealAn example for overloading bitwise-and: class Archive { public: std::ostream &operator&( std::ostream &out ) { return out << to_string(); } std::string to_string() { return "a string"; } };

Nice example of why C-style placement of pointer / reference characters is awkward, imo
 
The placement isn't as much a problem as the associativity.
I prefer Pascal's object := pointer^; style (don't mention C++.NET), but I forget how it applies to function definitions… merely swapping things in C would lead to std::ostream operator&( std::ostream &out ) & {
Ah, right, the entire return type is postfix, like a trailing-return-type. Further proving that C is wrong :P
 
@Potatoswatter If memory serves, functions are pretty similar: function f(x:integer) : integer Begin ...
@Potatoswatter Well, Pascal has (at least) its share of problems as well. The lack of return statement, and returning a value by assigning to the name of the function can lead to some ugly, contorted code at times.
 
@JerryCoffin Huh, I didn't realize there was no return! I was very young when I used it. Local functions missing from C can also be annoying, but not as much or as often. And C++ fixed that.
 
Xeo
4:53 AM
0
A: How can a templated "ResourceCache" load/create resources of type T, if they require different creation parameters/methods?

XeoIn C++11, this is rather easy with a variadic template and perfect-forwarding: #include <utility> template<class... Args> T* LoadResource(Args&&... args){ unsigned dest_index = /* pick it */ 0; cache[dest_index] = new T(std::forward<Args>(args)...); return cache[...

Anything I'm missing? I'm not that familiar with generalized resource caches and loading stuff into them
 
@Potatoswatter I don't have any books handy to check, but it would almost surprise me if Borland didn't add a return to their Pascal, so what you used may well have had one. Yeah, local functions were sometimes handy, but lambdas are just fine by me.
 
Yes, they did add return, AFAIR.
 
Xeo
0
Q: template meta programing and random number generation

pyCthonI'm trying to precompute random values using c++11's random library at compile time.I'm mostly following from examples. What am i doing wrong here ? using namespace std; #include <iostream> #include <vector> #include <chrono> #include <random> constexpr bool generate_ran...

...
 
Morning
 
@Xeo You're being so mean, trying stop the idea of a compiler that will know exactly when I'm going to run my program!
@ManofOneWay ...and a fine night to you too!
 
5:02 AM
:)
 
It's been a very long time since I've answered any newbie questions. But for some reason, I just answered two of them. Dunno why...
 
Hmm...I just noticed that the "newbie hints" has turned into a "code of conduct". I'm not sure I like the tone of that...
 
Xeo
Well, nobody really considers themselves a "newbie" and reads them, it seems...
 
@JerryCoffin I guess some of us were pretty annoyed by all the recent drive-bys.
 
Xeo
That said, we can always unpin it and repin the usual message
 
5:07 AM
@Mysticial I guess that's understandable.
@Xeo I'm certainly not trying to force anything -- I just happened to glance at it, and...
 
I was starting to get a bit annoyed too. But I have a fairly high annoyance tolerance before it makes me take any sort of action.
 
@Mysticial Probably like my theory on being polite to strangers: you never know when one might turn out to be a multi-billionaire who thinks "yeah, you were pretty nice, here have a couple million". I figure it's cheap, pleasant, and about as likely to make me a millionaire as buying a lottery ticket would!
 
Xeo
I'm polite to strangers because I'd want strangers to be polite to me too, easy as that.
 
I'm polite to strangers because I'm not a fan of pissing people off.
@JerryCoffin I don't usually answer newbie questions anymore. But I almost always leave a short answer in a comment if it's obvious.
 
Actually, I'm polite to strangers, even when (perhaps especially when) it might piss them off and/or they pretty clearly won't be polite in return. Did have a boss (years ago) who forbade any of us from ever saying "have a nice day" to customers though -- he'd gone to McDonalds (or somesuch) and been told to have a nice day, but was in a bad enough mood he decided he didn't like that...
 
5:18 AM
So in some sense, I still "answer" a lot of them - but not for whatever rep it could generate.
 
@Mysticial yeah, I've done that a times too, but got some rather pointed questions about why my comment hadn't been written as an answer when it was clearly an answer, not a comment. Sometimes you just can't win.
 
@JerryCoffin In those cases, especially if the OP acknowledges, then I'll make it an answer. But more often than not, one of the active repwhores will go ahead and take it.
Not that I'm bothered by that though - since I was once a repwhore.
 
Xeo
@Mysticial Same
 
If there was a gold pundit badge, I'd probably have like 10 of them by now. Since my "comment" answers usually get a ton of upvotes... lol
 
I tend to take a rather different route: find newbie questions that give me an excuse to write an answer something like: "imbue the istream with the digits_only locale from [previous answer X] and write the data out with the infix_ostream_iterator from [previous answer Y] and your whole program collapses down to three lines of code."
Being honest, it's probably not all that helpful to the OP in a lot of cases, but I enjoy it... :-)
 
Xeo
5:26 AM
hrhr, advertising your own answers... yeah, I do that too if possible
 
I'm also guilty of that.
 
@Xeo Not so much about advertising my own answers, as taking 100 lines so complex I can barely follow even the general idea, and turning it into two includes and three (or whatever) lines of utterly trivial code.
 
Xeo
I especially like cross-referencing my answers
 
Ah... found my most recent highly upvoted (comment) answer...
() -> {}... — Mysticial Jul 8 at 7:13
 
Xeo
@JerryCoffin I don't think I have any answers where I wrote a sweet little contraption to solve a problem that is reusable.
I don't know if I like the new format
Especially since I can't seem to find how many edits I made and how my voting is distributed, which was on the review site.
 
5:33 AM
The answer that I've most linked to. (as in - I would find any possible excuse to link it) was my 4 flops/cycle answer. I gave up after a while...
@Xeo I just noticed it... woah...
 
@Xeo I think the one I've referred to most often was probably the infix_ostream_iterator. Really is quite handy.
 
eh... there isn't a list of answers that I can scroll through... boo
57.7k close votes... nice...
 
@Xeo "Stats" toward the top-right corner.
 
Xeo
Nah, that's not it
 
I wish they would exclude votes on deleted posts from the stats on your profile.
They used to to that, then they included deleted posts.
 
Xeo
5:41 AM
The former page had my progress on Copy Editor and that other gold badge for the votes
 
Because then I can more freely downvote things that need to be deleted.
 
am I feeling kind today, should I really write a working example of the mersenne twister using template-meta programming?
 
*without messing up my up/down vote ratio.
 
@Mysticial IMO, if something needs to be closed or deleted, vote to do that. Downvoting should (IMO) be used primarily for things that need editing but might be salvageable (and worth salvaging).
 
@JerryCoffin I can't vote to delete answers unless they're downvoted.
Although, there are enough other flag-queue trawlers that do actually downvote all those "not and answer"s. And then I can freely add my delete vote to them.
 
5:45 AM
@Mysticial Oh, right. Good point. I was thinking more about down-voting questions than answers.
 
Questions I will close - but generally only if the OP has under 100 rep. For fear of retaliation downvotes.
*except for duplicate and migrate votes - those I'll cast any day.
 
@Mysticial That's another of times I'm completely oblivious -- I'm pretty sure I've never (even once) paid attention to the user's rep when deciding whether to vote to close or not. Maybe that's part of why I get as many downvotes as I do... Oh well, if they can down-vote me out of existence, so be it.
 
I used to not care at all. But now I actually have a few good answers on my top 5 list. So I rather not invite anybody to downvote them.
 
Meh. Bad answers with downvotes still serve to illustrate "gotchas" to discourage specific obvious approachse. The correct answer is not necessarily the whole story.
 
I usually post a positive-tone negative comment. Even if I don't downvote, it's enough to prevent upvotes and sometimes even invite others to downvote it.
 
5:51 AM
@Potatoswatter Good point -- a poor answer with a comment explaining the problem can be more useful than the answer being deleted -- it directly tells the reader to avoid this, and why. If there's just no answer there about (for example) while (!infile.eof()), the OP may well use it.
 
@Mysticial Is that the peak performance of 1 core of, like, a i7 or smth?
 
@DeadMG What are you referring to? That 4 flops/cycle question?
 
yeah
 
It's 4 flops with SSE per core.
On all current Intel processors.
8 flops with AVX per core
 
Isn't there parallel execution of SSE within one core?
Oh, floating-point. Never mind.
 
5:55 AM
@Potatoswatter Yes, you can issue up to 3 SSE instructions per cycle.
1 add/subtract, 1 multiply, and 1 shuffle
Of course shuffles don't count.
 
@Mysticial They don't count, they permute! Haw haw haw
3
 
@Potatoswatter ...
You can also do one or two SSE loads and one SSE store per cycle. But I'm not sure if they share the same port as the shuffle port.
 
@Mysticial So the max for, say, an i7 930 is 4x4xclockspeed?
 
Correct
Of course, it's almost impossible to get anywhere near that in a real application since:

1. You need to have a perfect 1-to-1 balance of add/subs and multiplies.
2. You need to have enough ILP to sustain the dual-issue per cycle.
3. You can't be stalling on memory...
Dense matrix is probably the only "real" application that actually gets near peak.
 
Well, the trick is to make sparse matrices look denser :)
 
6:08 AM
sparse matrices are branch bound... Data-dependent branching...
 
@Mysticial ...and for dense matrices, you can often do better on the GPU instead (depending on what you're doing, of course).
 
@JerryCoffin Yeah, pretty much...
 
A sparse matrix with no underlying pattern, yes. For my thesis project I analyzed circuit netlists and the narrowly constrained node connectivity meant you could treat them mostly the same, and remove most of the branches.
 
If I have a reference, and my RAM is broken resulting in the memory that stores the reference being 0, is using the reference UB?
Or does the standard assume working RAM?
 
@RadekSlupik If your ram is broken, you've probably got bigger problems than UB.
 
6:12 AM
@RadekSlupik Yeah, pretty much. The standard doesn't try to go into all the details, but it pretty much assumes that the machine actually works.
 
@RadekSlupik What is "storing the reference"? A C++ reference is an alias, it's notionally not stored anywhere.
 
@Potatoswatter whether a reference occupies memory is implementation-defined.
 
I was wondering, what are the rules for storage of reference members? Is that technically padding bytes?
@RadekSlupik Exactly. So how can it be UB?
 
Aren't references just pointers in disguise? (barring optimizations)
 
@Potatoswatter accessing memory that does not belong to you.
 
6:14 AM
@Potatoswatter I don't think they're considered padding bytes. If the implementation wants to store them, it can. It will disable any compiler-synthesized assignment operator (but you already knew that), whether the assignment would actually involve copying any bits or not.
 
Is it possible to catch a segfault? That could be very useful in some of the fault-tolerance stuff that I do.
 
@RadekSlupik Exactly. So how can it be UB?
 
Right now, I have fault-tolerance that's capable of recovering from almost any kind of soft-error that doesn't affect flow-control. But a single segfault due to a bad memory access from unstable hardware will still break the program.
 
@Mysticial Depends on the system. Often yes. VC++6 would turn such things into C++ exceptions by default. I think you can get more recent versions to do it if you want. Traditionally (e.g., in C), I seem to recall it arriving as a signal, which you could also handle.
 
@Mysticial Some systems allow it, and some languages specify it. But not in standard C on common desktop OS.
 
6:17 AM
Hmm... interesting. All I really need is a stack-unwind to a high enough function call that can handle it. And it's all good.
 
@JerryCoffin C++ exceptions are recoverable. C signals are often not.
 
In which case, I should probably experiment with it in C++ since exceptions will do just that.
Though I find that most hardware faults just result in a BSOD... no amount of fault-tolerance can recover from those...
 
@Mysticial Haha, I had a motherboard fail in a PowerBook G3 laptop… I hacked the firmware to avoid the address patterns that caused memory faults. Continued to use it for like 4 more years.
 
@Mysticial That, of course, is a problem. Unfortunately, a lot of PC hardware does its best to be as far from fault tolerant as possible (e.g., in a lot of cases, if you have memory with parity, a parity error will just shut down the machine without giving you any chance to even attempt to recover).
 
@Potatoswatter Holy shit...
 
6:22 AM
@Potatoswatter That's pretty impressive sounding.
 
I was at the time interning on the Apple firmware team… and my manager was the product manager for that model… but I did without help or use of the laboratory :)
 
@Mysticial Maybe instead of experimenting in C++, you should experiment in Verilog or VHDL.
 
Oh god... reminds me of my VLSI days... fun but brutal stuff...
 
@JerryCoffin C and signals have nothing to do with each other. Signals are a POSIX mechanism.
of course, one could argue that POSIX and C are more than coincidentally related, but still
 
@DeadMG Signals are standard C, but much is implementation-dependent.
 
6:26 AM
orly? I did not know that
 
For example there's std::alarm.
 
don't think standard C includes std:: anything
 
@Potatoswatter "Much" is almost understating things. Pretty much all you can do in a portable signal handler is assign a value to a variable of type volatile sigatomic_t, and then exit. Of course, a lot of code does more than that, but a lot of it also breaks, depending on the system.
 
6:48 AM
Morning
8.5.1 Aggregates
I have an inner class with just holding pointers, which I would like to initialize with 0 upon construction of the class.
 
Xeo
Outer() : _inner(), or _inner{} in C++11 should do it
 
it has to be c++98
 
Xeo
Then the former
 
Does _inner() work in Visual Studio? I seem to remember VS does not understand value initialization in all contexts...
 
just writing blah() in the initialization list? if the aggregate member is called blah works?
 
Xeo
6:51 AM
Should
 
It does according to the standard.
 
Xeo
It value initializes the member, which for aggregates value initializes all its members
 
humm let me make an example
 
Xeo
which for pointers means a null pointer
 
2
Q: C++ empty-paren member initialization - zeroes out memory?

jw.I originally wrote some code like this: class Foo { public: Foo() : m_buffer() {} private: char m_buffer[1024]; }; Someone who is smarter than me said that having the m_buffer() initializer would zero out the memory. My intention was to leave the memory uninitialized. I didn't have ...

 
Xeo
6:56 AM
> Now, in C++03, you will be guaranteed that b.a.c is zero. While in C++98, b.a.c will have some indeterminated value.
@Nils: So it depends on whether your compiler really follows 03 or 98. VC should follow 03
 
#include <cassert>

class Blah {
struct PrivatePointers { int *i; } p;
public:
Blah(): p() { assert(p.i == 0); }
};

int main() {
Blah blah;
}
 
@Xeo ...unless you're dealing with a really old version, of course.
 
@Xeo Ah I didn't know about 03.
so.. is it correct or does it just work?
 
Xeo
It is correct, in 03
 
6:57 AM
:)
no more memset
 
How many pointers are there? Can't you simply initialize them to 0 by hand, in case you use an older compiler?
 
Xeo
Better question: Why is the inner struct an aggregate and not just a struct with a user-defined ctor to zero them all out?
 
VC 08
What is the relevant section in the standard?
@Xeo Because I have in my app quite a few pointers in my inner struct.
 
Here is a VS bug related to value initialization. And here is another one. So I would be very careful to rely on value initialization.
 

« first day (639 days earlier)      last day (4308 days later) »