[llvm-bugs] [Bug 26336] New: Clang allows address of array with 'register' storage-class to be taken

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jan 27 05:06:18 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=26336

            Bug ID: 26336
           Summary: Clang allows address of array with 'register'
                    storage-class to be taken
           Product: clang
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: sneves at dei.uc.pt
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Example:

  extern int f(int *);

  int main() {
    register int x[1];  
    return f(x);
  }

The C99 standard, in footnote 100 of ยง6.7.1, states

> However, whether or not addressable storage is actually used, the address 
> of any part of an object declared with storage-class specifier register
> cannot be computed, either explicitly (by use of the unary & operator as 
> discussed in 6.5.3.2) or implicitly (by converting an array name to a 
> pointer as discussed in 6.3.2.1).

Clang already does the right thing for explicit & operators on register
variables. However it misses the implicit pointer decay of array types.
Thus the example above should fail with a "address of register variable 
requested" error message.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160127/b7615847/attachment.html>


More information about the llvm-bugs mailing list