Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 03 Jul 2003
Offline Last Active Yesterday, 11:44 PM

Topics I've Started

IOTD comments/discussion?

24 May 2014 - 08:52 AM

For a while we suffered from a lack of GDNet-submitted images, and had to switch to sourcing the IOTD (Image Of The Day) from the #screenshotsaturday twitter images. I'd say this has to all appearances been very successful, but somewhere along the way we seem to have lost in this transition is the ability to comment on the IOTDs. And I'm sad about this, because my experience was that some of the liveliest discussion threads on the old GDNet were around the IOTD galleries.


Now, I'd love to reboot that lively discussion, but having the images sourced from twitter presents some complications - primarily, the fact that the creator of any given IOTD image may or may not have an account here on GDNet. I'm worried that the image's creator may not know that the image is being commented on and discussed on our forums, and may not be able to respond and/or defend himself if the discussion turns unpleasant.


This doesn't have to be an insurmountable problem:

  • We have fairly aggressive moderation of abusive comments across the site (would you agree?).
  • We have twitter login integration, so any twitter user should be able to login here (does it work? I've never tried).
  • We could potentially tweet back a reply with a link to the discussion here (might be construed as spam?).

So I guess my question is: what do you all think about this?

Strange array overflow (aka WTF I missing here?)

08 April 2014 - 09:14 PM

So I have this fun little function, which reliably crashes at line D (commented below), only if TILE_SIZE is set to an odd number:
const int TILE_SIZE = 7;

Tile *create(const std::array<vector3, 4> &corners) {
   std::vector<vector3> verts; // line A
   std::array<vector3, TILE_SIZE/2> past; // line B

   for (int i = 0; i < TILE_SIZE; ++i) {
      vector3 hi = cml::lerp(corners[0], corners[1], i / float(TILE_SIZE-1));
      vector3 lo = cml::lerp(corners[3], corners[2], i / float(TILE_SIZE-1));

      for (int j = 0; j < TILE_SIZE; ++j) {
         vector3 v = cml::lerp(lo, hi, j / float(TILE_SIZE-1)) );

         if (((i & 1) == 0 || i == TILE_SIZE-1) && ((j & 1) == 0 || j == TILE_SIZE-1)) {
            past[j/2] = v; // line C

         verts.push_back(v); // line D

// ...
The debugger tells me that this is because the verts array has an impossibly large size, which can be fixed by increasing the size of the past array by 1, commenting line C, or swapping lines A and B.

"Array overflow", you say, "silly dev has an off-by-one error in line C", you say. And I'd agree with you, except I can't see it for the life of me. With TILE_SIZE=7, the past array should have a length of 7/2=3, and the inner for loop counts up to (7-1)/2=3, which seems fine, and has been validated with much printf-debugging...

Any ideas to relieve my current anxiety?

C++ trivia

21 January 2014 - 09:17 AM

Everyone knows that taking a reference to a temporary is a bad idea:
int getX() {
    return 5;

int &x = getX();
But how about a const reference?
int getY() {
    return 10;

const int &y = getY();
It turns out that unlike the first case, storing a const reference to a temporary actually extends the lifetime of the temporary to lifetime of the const reference (read Herb Sutter on the topic).
Entertainingly enough, I learned this piece of C++ trivia when Coverity's static analysis tool tried to tell me that returning a const reference to a temporary was illegal. All I can say is yay for code checking tools that don't understand the C++ standard...

Name for unusual narrative mode?

08 December 2013 - 06:08 PM

What would you call a mode which includes a first person narrator, who addresses the main character in the second person, and both the narrator and the subject are clearly distinct from the audience?


(other than 'disturbing' - I appreciate that this is not a narrative mode to be taken lightly)


I swear I have read a book (or at least short story) written in this fashion, but I can't for the life of me put a name to that either.

goto considered harmful within global macros

13 October 2013 - 07:41 AM

I was really quite surprised when I first attempted to add error checking at work, and my compilation failed with a error: use of undeclared label 'onError'.


From a ubiquitous global header in a (thankfully recently deceased) library within our project:

#define CheckSuccess(condition) do { \
    if (!condition) { \
        goto onError; \
    } \
} while (0) 

The idea that an error checking macro would require the current function to implement a specifically named label for error cleanup (or, indeed, that there would be significant error cleanup not handled by RAII), is a little unpleasant to me...


I should probably add that the author of this particular gem thought that they were working around the lack of exception handling on our target platform.