[cfe-commits] [patch] fix for crash-on-invalid when recovering from an invalid variable name & deduced array dimension in C++11

David Blaikie dblaikie at gmail.com
Tue Feb 14 00:39:58 PST 2012

The patch/example is easier to understand than the description, perhaps.

struct foo {
  operator int[](){};

crashes - clang seems to be parsing 'operator int' as a member
variable name (? why is that? no type was provided before the name,
and it seems hardly likely a user would've mistakenly tried to name
their variable 'operator int' & much more likely they've messed up a
member function definition), sees the {} thinking its an in-class
initializer and the [] a deduced array bound. At this point the parser
tries to invalidate the declaration which is non-existent because of
the bogus name, and dereferences null.

Add the null check (there's a smattering of similar checks littered
around this area, so that seems like a reasonable solution - the
erroneous error recovery highlighted above not withstanding).

Thanks for the review/comments/help,
- David
-------------- next part --------------
A non-text attachment was scrubbed...
Name: crash-on-invalid-name.diff
Type: application/octet-stream
Size: 1595 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120214/7e2d3b6f/attachment.obj>

More information about the cfe-commits mailing list