Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ Address-of nullchecking

Name: Anonymous 2008-10-24 3:39

Impl& impl;

That little motherfucking line of code in a header is pissing me off.  Why?  Because it eventually causes an access violation at the line:

if(!impl.mProcessTimer.checkExpirationAndReset(SECS_BETWEEN_PROCESS))

And I have no idea how to check for nulls in an address-of situation.  Regular pointers?  Sure, but whenever I try if(!impl) or some other more convoluted variation of that, MSVC screams about invalid operators. 

Halp plz.

Name: Anonymous 2008-10-24 3:59

http://en.wikipedia.org/wiki/C%2B%2B_reference#Relationship_to_pointers
While pointers can be made invalid through a variety of mechanisms, ranging from carrying a null value to out-of-bounds arithmetic to illegal casts to producing them from random integers, a reference only becomes invalid in two cases:

    * If it refers to an object with automatic allocation which goes out of scope,
    * If it refers to an object inside a block of dynamic memory which has been freed.

The first is easy to detect automatically if the reference has static scoping, but is still a problem if the reference is a member of a dynamically allocated object; the second is more difficult to assure. These are the only concern with references, and are suitably addressed by a reasonable allocation policy.

Name: Anonymous 2008-10-24 4:01

References are by definition not allowed to be NULL. If this happens, your design is broken.

Name: Anonymous 2008-10-24 4:07

Just use regular pointers and check/deref them explicitly.

Pointers that basically dereference automatically are a little confusing.

Name: Anonymous 2008-10-24 4:30

Name: Anonymous 2008-10-24 4:47

>>5
Oh, yousef

Name: Anonymous 2008-10-24 7:14

>>1
Just use valgrind

Name: Anonymous 2008-10-24 11:11

>>7
Seconded. Valgrind (specifically memcheck) may be the single-greatest debugging tool ever created.

Name: Anonymous 2008-10-24 11:30

>>8
Xcode's fix-and-continue ranks pretty high up there, though.

Name: Anonymous 2008-10-24 15:35

Thing is, it's not my code.  I'm modding Second Life in order to bypass hardware bans, and >>1 is fresh out of their trunk SVN.  This is released software, too, so I don't get wtf is going on.

Compiling with Visual C++ 2005 Express since cross-compiling on Lunix fails for some reason.

Name: Anonymous 2008-10-24 15:37

Have you considered that impl.mProcessTimer might be null?

Name: Anonymous 2008-10-24 15:49

>>10
Why don't you pull from a stable branch instead of the trunk?

Name: Anonymous 2008-10-24 16:02

The best thing about valgrind is when you use it and find out there are fucking errors in some of the C standard library. Fuck off Dennis Ritchie.

Name: Anonymous 2008-10-24 16:23

>>13
You probably mean fuck off Richard Stallman, if you're using glibc.

Name: Anonymous 2008-10-24 16:35

>>14
I'm not using glibc.

Name: Anonymous 2008-10-24 19:50

>>9
You would not say that if you were programming in JAVA using Eclipse.

Name: Anonymous 2008-10-24 20:16

>>13
I'm pretty sure that's what that Debian guy said about the OpenBSD guys when he tried to “fix” OpenSSL.

Name: Anonymous 2008-10-25 0:31

>>10
Shoopedlife

Name: Anonymous 2008-10-25 0:56

>>16
No, if that was the case, I would definitely have to mention a certain psytrance band.

Name: Anonymous 2008-10-25 9:50

>>19
I hope you don't mean ``Infected Mushroom'', because they are most definitely not psytrance.

Name: Anonymous 2008-10-25 10:40

>>5
C++ does things differently then my beloved, true language C. Baaaaaaaw!

Name: Anonymous 2008-10-25 11:14

>>10
You forgot to
[c]#define FURRYFAGGOT[/c]

Name: Anonymous 2008-10-25 11:26

>>21
Sepples is shit, fuck yall

Name: Anonymous 2008-10-25 12:44

Name: Anonymous 2008-10-25 14:23

Infected Mushroom is definitely not psytrance, I don't give a flying fuck what people at that website think.

Xarn, over and out.

Name: Anonymous 2008-10-25 21:39

Psytrance is psychedelic. Infected Mushroom is just gaytrance.

Name: Anonymous 2008-10-25 22:01

>>20,25,26

Old Infected Mushroom is definitely psytrance — that is, everything before ``IM the Supervisor'' (or ``Converting Vegetarians'' disc 2 if you want to be a bit more pessimistic). Nowadays they seem to be trying to make psychedelic pop.

Sincerely,
Someone who was listening to goa and psychedelic trance years before you fags found it on the internet

Name: Anonymous 2008-10-25 23:05

>>27
Hurr trance hipsters.

Protip: nobody actually gives a shit.

Name: Anonymous 2008-10-25 23:21

I give a shit. So go fuck yourself >>28.

Name: Anonymous 2008-10-26 0:14

>>27
No literate person can enjoy Infected Mushroom.

Name: Anonymous 2008-10-26 1:50

>>30
I PROGRAM IN C# WHILE LISTENING TO INFECTED MUSHROOM BECAUSE IT MAKES ME FEEL 1337

Name: Anonymous 2008-10-26 2:06

I enjoy Infected Mushroom. So go fuck yourself >>30.

Name: Anonymous 2008-10-26 10:33

>>32
Wake me up before I change again
Remind me the story that I won´t get insane
Tell me why it´s always the same
Explain me the reason why I´m so much in pain

Name: Anonymous 2008-10-26 10:37

>>33
THESE WOUND WON'T SEEM TO HEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAL

Name: Anonymous 2008-10-26 10:41

>>32
And you are illiterate. My point has been proved.

Name: Anonymous 2008-10-26 19:28

My point has been proved.
You should be using the present perfect there. With such poor grammar skills on your part, I don't see how you are in the position to determine the literacy of others.

Name: Anonymous 2008-10-26 20:59

>>36

Maybe you should check your dictionary before spouting ignorant nonsense.

For complex historical reasons, [b]prove[b] developed two past participles: proved and proven. Both are correct and can be used more or less interchangeably: : this hasn't been proved yet;: this hasn't been proven yet. Proven is the more common form when used as an adjective before the noun it modifies: : a proven talent (not : a proved talent). Otherwise, the choice between : proved and : proven is not a matter of correctness, but usually of sound and rhythm—and often, consequently, a matter of familiarity, as in the legal idiom : innocent until proven guilty.

Name: Anonymous 2008-10-26 22:41

>>35
7/10

Name: Anonymous 2008-10-27 0:19

GOD you motherfuckers are worse than furries.

Name: Anonymous 2008-10-27 0:23

>>39
My furry friend Xarn would disagree with you.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List