public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99072] New: [modules] Compiling header unit with partial preprocessing (-E -fdirectives-only) twice causes CRC mismatch
@ 2021-02-11 14:47 boris at kolpackov dot net
  2021-02-16 15:34 ` [Bug c++/99072] " nathan at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: boris at kolpackov dot net @ 2021-02-11 14:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99072

            Bug ID: 99072
           Summary: [modules] Compiling header unit with partial
                    preprocessing (-E -fdirectives-only) twice causes CRC
                    mismatch
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: boris at kolpackov dot net
  Target Milestone: ---

With partial preprocessing (-E -fdirectives-only) compiling the same header
with the same options twice results in two CRC-incompatible .gcm files:

cat <<EOF >string.hxx 
#include <string>
EOF

cat <<EOF >hello.mxx
export module hello;

import "string.hxx";

export std::string format_hello (const char* n)
{
  return "Hello, " + std::string (n) + '!';
}
EOF

cat <<EOF >main.cxx
#include <cassert>

import "string.hxx";
import hello;

int main ()
{
  assert (format_hello ("World") == "Hello, World!");
}
EOF

cat <<EOF >hello.txt
./string.hxx string.so.gcm
hello hello.so.gcm
EOF

cat <<EOF >main.txt
./string.hxx string.gcm
hello hello.so.gcm
EOF

g++ -std=c++2a -fmodules-ts -fmodule-mapper=hello.txt -E -fdirectives-only
-fmodule-header -x c++-header -o string.so.ii string.hxx
g++ -std=c++2a -fmodules-ts -fmodule-mapper=hello.txt -fpreprocessed
-fdirectives-only -fmodule-header -x c++-header string.so.ii

g++ -std=c++2a -fmodules-ts -fmodule-mapper=hello.txt -x c++ -c hello.mxx

g++ -std=c++2a -fmodules-ts -fmodule-mapper=main.txt -E -fdirectives-only
-fmodule-header -x c++-header -o string.ii string.hxx
g++ -std=c++2a -fmodules-ts -fmodule-mapper=main.txt -fpreprocessed
-fdirectives-only -fmodule-header -x c++-header string.ii

g++ -std=c++2a -fmodules-ts -fmodule-mapper=main.txt -x c++ -c main.cxx
In module imported at main.cxx:5:1:
hello: error: import ‘./string.hxx’ has CRC mismatch

The really strange thing is that the .ii files are identical:

diff string.ii string.so.ii && echo same
same

Also, there is no error if to compile string.hxx without -E -fdirectives-only:

g++ -std=c++2a -fmodules-ts -fmodule-mapper=hello.txt -fmodule-header -x
c++-header string.hxx

g++ -std=c++2a -fmodules-ts -fmodule-mapper=main.txt -fmodule-header -x
c++-header string.hxx

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-03-04  7:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-11 14:47 [Bug c++/99072] New: [modules] Compiling header unit with partial preprocessing (-E -fdirectives-only) twice causes CRC mismatch boris at kolpackov dot net
2021-02-16 15:34 ` [Bug c++/99072] " nathan at gcc dot gnu.org
2021-02-17  7:15 ` boris at kolpackov dot net
2021-02-17 18:58 ` nathan at gcc dot gnu.org
2021-02-18  4:17 ` boris at kolpackov dot net
2021-02-23 20:17 ` nathan at gcc dot gnu.org
2021-02-24 17:14 ` cvs-commit at gcc dot gnu.org
2021-02-24 17:15 ` nathan at gcc dot gnu.org
2021-03-04  7:54 ` boris at kolpackov dot net

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).