News for hackers. Stuff that matters.
Re:Ill-Advised C++ Rant, Part 2 (2016) by gruez on Wednesday October 25, 2017 @04:01PM (#15553608)
an empty struct has a size of 1 byte.

    struct Widget{  
    };

    Widget widgets[256];
    printf("%d %d", sizeof(widgets), sizeof(Widget));
prints out

    256 1
if there are 0 elements, there are no issues because it's 0/x = 0.
Re:Ill-Advised C++ Rant, Part 2 (2016) by wrsh07 on Wednesday October 25, 2017 @04:35PM (#15553984)
the point is that they're indexing into an array of unknown size.
Re:Ill-Advised C++ Rant, Part 2 (2016) by gruez on Wednesday October 25, 2017 @04:55PM (#15554179)
indexing in that case doesn't trigger a dereference, since it's being passed to the sizeof operator.