public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99642] New: Compiler error while using precompiled header and -Wmismatched-tags flag
@ 2021-03-18 12:08 alexey.ismagilov at rfdyn dot ru
  2021-03-18 14:23 ` [Bug c++/99642] " msebor at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: alexey.ismagilov at rfdyn dot ru @ 2021-03-18 12:08 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99642
           Summary: Compiler error while using precompiled header and
                    -Wmismatched-tags flag
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alexey.ismagilov at rfdyn dot ru
  Target Milestone: ---

Steps to reproduce:
===================

$ cat pch.h
#include <string>

$ cat main.cpp 
#include <fstream>
#include "pch.h"
int main () {}

$ /usr/bin/g++ -Wmismatched-tags -c pch.h -o pch.h.gch

$ /usr/bin/g++ -Wmismatched-tags -include pch.h main.cpp
main.cpp:3:14: internal compiler error: in diag_mismatched_tags, at
cp/parser.c:31360
    3 | int main () {}
      |              ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://bugs.archlinux.org/> for instructions.

Additional info:
================

$ /usr/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/usr/bin/g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib
--libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl
--with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit
--enable-cet=auto --enable-checking=release --enable-clocale=gnu
--enable-default-pie --enable-default-ssp --enable-gnu-indirect-function
--enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id
--enable-lto --enable-multilib --enable-plugin --enable-shared
--enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-libunwind-exceptions --disable-werror
gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (GCC)

# pacman -F /usr/bin/g++
usr/bin/g++ is owned by core/gcc 10.2.0-6

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

* [Bug c++/99642] Compiler error while using precompiled header and -Wmismatched-tags flag
  2021-03-18 12:08 [Bug c++/99642] New: Compiler error while using precompiled header and -Wmismatched-tags flag alexey.ismagilov at rfdyn dot ru
@ 2021-03-18 14:23 ` msebor at gcc dot gnu.org
  2021-03-18 14:30 ` msebor at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-03-18 14:23 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
             Status|UNCONFIRMED                 |NEW
                 CC|                            |msebor at gcc dot gnu.org
   Last reconfirmed|                            |2021-03-18
     Ever confirmed|0                           |1

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed.  The assert below fails:

      /* For implicit instantiations of a primary template look up
         the primary or partial specialization and use it as
         the expected class-key rather than using the class-key of
         the first reference to the instantiation.  The primary must
         be (and inevitably is) at index zero.  */
      tree spec = specialization_of (type);
      cdlguide = class2loc.get (spec);
      gcc_assert (cdlguide != NULL);

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

* [Bug c++/99642] Compiler error while using precompiled header and -Wmismatched-tags flag
  2021-03-18 12:08 [Bug c++/99642] New: Compiler error while using precompiled header and -Wmismatched-tags flag alexey.ismagilov at rfdyn dot ru
  2021-03-18 14:23 ` [Bug c++/99642] " msebor at gcc dot gnu.org
@ 2021-03-18 14:30 ` msebor at gcc dot gnu.org
  2021-03-18 20:33 ` msebor at gcc dot gnu.org
  2021-12-14  7:23 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-03-18 14:30 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |10.2.0, 11.0

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
Likely introduced in r279480 (GCC 10) when -Wmismatched-tags was added.  Not a
regression since the option is off by default.

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

* [Bug c++/99642] Compiler error while using precompiled header and -Wmismatched-tags flag
  2021-03-18 12:08 [Bug c++/99642] New: Compiler error while using precompiled header and -Wmismatched-tags flag alexey.ismagilov at rfdyn dot ru
  2021-03-18 14:23 ` [Bug c++/99642] " msebor at gcc dot gnu.org
  2021-03-18 14:30 ` msebor at gcc dot gnu.org
@ 2021-03-18 20:33 ` msebor at gcc dot gnu.org
  2021-12-14  7:23 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-03-18 20:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
Type and spec are the messages facet, but the same problem happens with other
types.  A simpler test case is:

$ (set -x && cat pch.h && cat main.cpp)
+ cat pch.h
#include <iosfwd>
+ cat main.cpp
#include <ios>
#include "pch.h"
int main () {}

which aborts for basic_istream (and basic_ostream, but no other types).

The problem is that some of these types are added to class2loc mapping as they
should be, but with a different address than when they're looked up. 
Instrumenting the code to print out the tree node (as @%p) shows this.  The
address after type_decl, @0x7fdba48705f0, in the first message, doesn't match
the address after spec, @0x10001df1f0:

/build/gcc-master/x86_64-pc-linux-gnu/libstdc++-v3/include/iosfwd:83:11: note:
add: type_decl @0x7fdba48705f0: ‘class std::basic_istream<_CharT, _Traits>’,
exist: 0, def_p: 0, complete: 0, template_decl: 1
   83 |     class basic_istream;
      |           ^~~~~~~~~~~~~
and then
/build/gcc-master/x86_64-pc-linux-gnu/libstdc++-v3/include/iosfwd:83:11: note:
diag_mismatched_tags: type_decl: ‘class std::basic_istream<_CharT, _Traits>’
   83 |     class basic_istream;
      |           ^~~~~~~~~~~~~
main.cpp:3:14: note: diag_mismatched_tags: type: ‘std::basic_istream<_CharT,
_Traits>’, spec @0x10001df1f0: ‘std::basic_istream<_CharT, _Traits>’
    3 | int main () {}
      |              ^

A record of basic_istream exists but can't be looked up.

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

* [Bug c++/99642] Compiler error while using precompiled header and -Wmismatched-tags flag
  2021-03-18 12:08 [Bug c++/99642] New: Compiler error while using precompiled header and -Wmismatched-tags flag alexey.ismagilov at rfdyn dot ru
                   ` (2 preceding siblings ...)
  2021-03-18 20:33 ` msebor at gcc dot gnu.org
@ 2021-12-14  7:23 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-14  7:23 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |GC

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Seems to me this map is not PCH/GTY safe even:
  /* A mapping between a TYPE_DECL for a class and the class_decl_loc_t
     description above.  */
  typedef hash_map<tree_decl_hash, class_decl_loc_t> class_to_loc_map_t;
  static class_to_loc_map_t class2loc;

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

end of thread, other threads:[~2021-12-14  7:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-18 12:08 [Bug c++/99642] New: Compiler error while using precompiled header and -Wmismatched-tags flag alexey.ismagilov at rfdyn dot ru
2021-03-18 14:23 ` [Bug c++/99642] " msebor at gcc dot gnu.org
2021-03-18 14:30 ` msebor at gcc dot gnu.org
2021-03-18 20:33 ` msebor at gcc dot gnu.org
2021-12-14  7:23 ` pinskia at gcc dot gnu.org

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).