<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - preprocessor incorrectly replaces "macro defined as nothing" with # of spaces in name"
   href="http://llvm.org/bugs/show_bug.cgi?id=22031">22031</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>preprocessor incorrectly replaces "macro defined as nothing" with # of spaces in name
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.4
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>dgoldman@ehdp.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Here is my version:

$ clang --version
Ubuntu clang version 3.4-1ubuntu3 (based on LLVM 3.4)
Target: x86_64-pc-linux-gnu
Thread model: posix

Here is example showing the alleged bug:

$ cat clang-2.h
#define MACRO_NAME
MACRO_NAME Y

$ clang -P -E clang-2.h

           Y

$ gcc -P -E clang-2.h
 Y

When MACRO_NAME is defined as "nothing", clang replaces with same # of spaces
as the macro name length. Instead, it should replace with one space (like gcc),
whether MACRO_NAME, MACRO, or whatever macro name.

I know the C compiler will not care about the extra spaces. But in support of
getting this called a bug and fixing it, I offer:

1) I (and others) use cpp to process other files where the extra spaces DO
matter. So this is a practical matter, not a theoretical quibble. For example,
I use cpp to produce input files to nroff, and spaces matter in that situation.
I only went to the effort of filing this bug report because the different clang
behavior does matter to me (and others).

2) I do not have the option to use a different preprocessor, such as m4 or the
few others available. I have researched and tested them a lot. I must use cpp.
Specifically, I have C header files used to compile C code, and also used to
produce html and text help files.

3) The clang behavior is illogical. It makes no sense to replace "macro defined
as nothing" with the same number of spaces as the macro name. What's the
benefit or rationale? I see none.

4) clang differs from gcc in this case. What reason for the difference? I see
none. And the difference seems to go against the idea that clang can be a
drop-in replacement for gcc.

5) This bug seems easily fixed (assuming familiarity with LLVM source code,
which I am not). It must take more effort (and code) to replace "macro defined
as nothing" with same number of spaces as macro name length. It must be simpler
to always replace with one space. So (besides being more correct) fixing the
bug would seem to simplify the LLVM source code.</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>