<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 - Segmentation fault when a macro is defined as nothing"
   href="https://bugs.llvm.org/show_bug.cgi?id=48747">48747</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Segmentation fault when a macro is defined as nothing
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>flang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </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>Frontend
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>farisrehman@hotmail.co.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>David.Truby@arm.com, jperier@nvidia.com, kirankumartp@gmail.com, llvm-bugs@lists.llvm.org, sscalpone@nvidia.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>A bug has been discovered regarding macros with an empty definition. The
initial reporting can be found here: <a href="https://reviews.llvm.org/D93401#2488477">https://reviews.llvm.org/D93401#2488477</a>

The error is produced by both f18 and flang-new, suggesting it is not a driver
issue. I am not familiar with the frontend, but the error seems to occur where
the following holds true with an empty string:
<a href="https://github.com/llvm/llvm-project/blob/main/flang/lib/Parser/preprocessor.cpp#L314">https://github.com/llvm/llvm-project/blob/main/flang/lib/Parser/preprocessor.cpp#L314</a> 

I've reproduced this error, from commit
d58512b2e31a255dccc2c9a351a4e47b2b4c9f79 as head:
frehman@server-1:~/llvm-project$ cat a.f90
program X
end
frehman@server-1:~/llvm-project$ build/bin/f18 -E -DX= a.f90
Segmentation fault
frehman@server-1:~/llvm-project$ build/bin/flang-new -E -DX= a.f90
PLEASE submit a bug report to <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash
backtrace.
Stack dump:
0.      Program arguments: /home/frehman/llvm-project/build/bin/flang-new -fc1
-E -D X= -o - a.f90
 #0 0x0000000001d613aa llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
/home/frehman/llvm-projec
t/llvm/lib/Support/Unix/Signals.inc:565:11
 #1 0x0000000001d6155b PrintStackTraceSignalHandler(void*)
/home/frehman/llvm-project/llvm/lib/Suppo
rt/Unix/Signals.inc:632:1
 #2 0x0000000001d5fc53 llvm::sys::RunSignalHandlers()
/home/frehman/llvm-project/llvm/lib/Support/Si
gnals.cpp:70:5
 #3 0x0000000001d61c85 SignalHandler(int)
/home/frehman/llvm-project/llvm/lib/Support/Unix/Signals.i
nc:407:1
 #4 0x00007f8161803140 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x14140)
 #5 0x00000000040aae72
Fortran::parser::OffsetToProvenanceMappings::Map(unsigned long) const /home/f
rehman/llvm-project/flang/lib/Parser/provenance.cpp:105:47
 #6 0x00000000040bd299
Fortran::parser::TokenSequence::GetIntervalProvenanceRange(unsigned long, uns
igned long) const
/home/frehman/llvm-project/flang/lib/Parser/token-sequence.cpp:305:38
 #7 0x00000000040bd369 Fortran::parser::TokenSequence::GetProvenanceRange()
const /home/frehman/llvm
-project/flang/lib/Parser/token-sequence.cpp:313:10
 #8 0x0000000003afe447
Fortran::parser::Preprocessor::MacroReplacement(Fortran::parser::TokenSequenc
e const&, Fortran::parser::Prescanner&)
/home/frehman/llvm-project/flang/lib/Parser/preprocessor.cpp
:315:48
 #9 0x0000000003b10547 Fortran::parser::Prescanner::Statement()
/home/frehman/llvm-project/flang/lib
/Parser/prescan.cpp:165:36
#10 0x0000000003b0ff25
Fortran::parser::Prescanner::Prescan(Fortran::common::Interval<Fortran::parse
r::Provenance>) /home/frehman/llvm-project/flang/lib/Parser/prescan.cpp:74:3
#11 0x0000000003af2d11
Fortran::parser::Parsing::Prescan(std::__cxx11::basic_string<char, std::char_
traits<char>, std::allocator<char> > const&, Fortran::parser::Options)
/home/frehman/llvm-project/fl
ang/lib/Parser/parsing.cpp:81:14
#12 0x0000000001d73aa4 Fortran::frontend::FrontendAction::Execute()
/home/frehman/llvm-project/flang
/lib/Frontend/FrontendAction.cpp:56:3
#13 0x0000000001d67f23
Fortran::frontend::CompilerInstance::ExecuteAction(Fortran::frontend::Fronten
dAction&)
/home/frehman/llvm-project/flang/lib/Frontend/CompilerInstance.cpp:151:23
#14 0x0000000001d78660
Fortran::frontend::ExecuteCompilerInvocation(Fortran::frontend::CompilerInsta
nce*)
/home/frehman/llvm-project/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:83:8
#15 0x0000000001c56728 fc1_main(llvm::ArrayRef<char const*>, char const*)
/home/frehman/llvm-project
/flang/tools/flang-driver/fc1_main.cpp:57:11
#16 0x0000000001c5222c ExecuteFC1Tool(llvm::SmallVectorImpl<char const*>&)
/home/frehman/llvm-projec
t/flang/tools/flang-driver/driver.cpp:60:5
#17 0x0000000001c51bed main
/home/frehman/llvm-project/flang/tools/flang-driver/driver.cpp:89:7
#18 0x00007f81612c6d0a __libc_start_main ./csu/../csu/libc-start.c:308:16
#19 0x0000000001c5188a _start
(/home/frehman/llvm-project/build/bin/flang-new+0x1c5188a)
flang-new: error: unable to execute command: Segmentation fault
flang-new: error: flang frontend command failed due to signal (use -v to see
invocation)
flang-new version 12.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/frehman/llvm-project/build/bin
flang-new: note: diagnostic msg: Error generating preprocessed source(s) - no
preprocessable inputs.
frehman@server-1:~/llvm-project$</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>