<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 - Regression in batch file quote handling"
   href="https://bugs.llvm.org/show_bug.cgi?id=39506">39506</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Regression in batch file quote handling
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>release blocker
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Support Libraries
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jh7370.2008@my.bristol.ac.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>We have a downstream user of clang who is using the preprocessor to define
macros in an assembly file. Here is an example snippet:

// bar.s
.section .rodata,"a"
.asciz FOO

They preprocess and assemble the code as part of a larger batch file. The
relevant command looks something like this:

// run.bat
clang.exe -c -x assembler-with-cpp -DFOO="""%~1""" bar.s -o bar.out.o

Usage:
C:\Work>run.bat 123

This used to work fine, but a recent change to LLVM's command-line parsing
appears to have broken the behaviour of how the quotes were handled.
Previously, one set of double quotes were removed, and then each pair of double
quotes became a single double quote in the macro, so the resultant value of FOO
was "123" (i.e. the line in the assembly became .asciz "123").

Following the change, all the quotes look to be discarded, such that the value
of FOO becomes 123, leading to the assembly output '.asciz 123', which is
invalid asm, and results in a compiler error:
bar.s:2:8: error: expected string in '.asciz' directive
.asciz 123

(Note that running this directly on the command-line also results in the error
when run via cmd, when it did not previously)

I bisected the change causing the regression to r341988: "[Support] Avoid
calling CommandLineToArgvW from shell32.dll".

Filing this as a release blocker, as it could easily break people's builds when
they are using batch files, although I acknowledge that the user in this case
could work-around by doing '.asciz "FOO"' instead, so feel free to change the
severity if you think I'm wrong.</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>