[LLVMbugs] [Bug 13500] Wrong type for variable sized array when size comes from Objective-C method invocation

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Aug 1 10:32:49 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=13500

Douglas Gregor <dgregor at apple.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #1 from Douglas Gregor <dgregor at apple.com> 2012-08-01 12:32:49 CDT ---
What's happening is that 

  int buf[ [obj count] ];

is being parsed as 

  int buf

with a C++11 attribute [[obj count]] (which gets ignored). Top-of-tree Clang
disambiguates this to what the programmer actually expects, which is a VLA
whose size is determined by [obj count].

The workaround, in the meantime, is to wrap a set of parentheses around the
message send, e.g.,

  int buf[ ([obj count]) ];

or more the VLA size computation out to a separate variable

  NSUInteger n = [obj count];
  int buf[n];

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list