<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Request for LangRef clarification: allocation size of global variable declaration"
   href="https://bugs.llvm.org/show_bug.cgi?id=45681">45681</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Request for LangRef clarification: allocation size of global variable declaration
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Documentation
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>General docs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>mschiffer@universe-factory.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Working on Rust, we have come across the question whether LLVM makes any
assumptions about the allocation size of declared global variables based on
their type when the definition is unknown (or, turning it around, if it is
guaranteed that LLVM makes no such assumptions).

It seems fine to access data (for example using getelementptr inbounds) past
the "end" of such a global variable at least on some cases - I've noticed that
clang compiles a `extern char foo[];` to `@foo = external global [0 x i8],
align 1` (and a comment in llvm/test/Analysis/BasicAA/global-size.ll backs
this).

What is not entirely clear to us is whether such accesses are *always* valid
(given that a definition of appropriate length comes in at link time), in
particular:

- when the length of the declared type is not 0
- when the declared type is not an array, but a struct, and the last element of
the struct is no array

If all of this is indeed valid, it would be great if such a statement could be
added to the LangRef.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>