<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 - __FILE__ is modified whenever "#include __FILE__" is encountered"
   href="https://bugs.llvm.org/show_bug.cgi?id=44480">44480</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>__FILE__ is modified whenever "#include __FILE__" is encountered
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>9.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </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>C
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>omoikane@uguu.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=22994" name="attach_22994" title="Demonstration of how __FILE__ is modified">attachment 22994</a> <a href="attachment.cgi?id=22994&action=edit" title="Demonstration of how __FILE__ is modified">[details]</a></span>
Demonstration of how __FILE__ is modified

Clang's preprocessor appears to prepend "./" to __FILE__ every time it
encounters "#include __FILE__" in a source code.  This can be observed by how 3
different strings are printed for this code:

  #ifndef INCLUDE_GUARD
  #define INCLUDE_GUARD
  #include <stdio.h>
  int main(int argc, char **argv)
  {
      puts(__FILE__);
      #include __FILE__
      puts(__FILE__);
      #include __FILE__
      puts(__FILE__);
      return 0;
  }
  #endif

<a href="https://gcc.godbolt.org/z/JTx2Np">https://gcc.godbolt.org/z/JTx2Np</a>

If a piece of code manages to #include itself a finite but large number of
times, "#include __FILE__" will eventually fail because __FILE__ contains a
string longer than what's supported by the local file system.

The preprocessor should just keep __FILE__ constant.  Clang 3.5.1 and earlier
and all versions of GCC has the expected behavior, Clang 3.6 and later appears
to modify __FILE__.</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>