public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98306] New: invalid use of incomplete type 'struct grammar'
@ 2020-12-15 22:39 slyfox at gcc dot gnu.org
  2020-12-15 22:58 ` [Bug c++/98306] " jakub at gcc dot gnu.org
  2020-12-18 22:17 ` slyfox at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: slyfox at gcc dot gnu.org @ 2020-12-15 22:39 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98306
           Summary: invalid use of incomplete type 'struct grammar'
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: slyfox at gcc dot gnu.org
  Target Milestone: ---

Noticed error-looking warning when was reducing unrelated boost ICE. Minimal
reproducer:

  // $ cat bug.cpp
  extern struct grammar *target_grammar;

  template <typename T> void define(void) { target_grammar->derived(); }

$ g++-11.0.0 -c bug.cpp; echo $?
bug.cpp: In function 'void define()':
bug.cpp:3:57: warning: invalid use of incomplete type 'struct grammar'
    3 | template <typename T> void define(void) { target_grammar->derived(); }
      |                                                         ^~
bug.cpp:1:15: note: forward declaration of 'struct grammar'
    1 | extern struct grammar *target_grammar;
      |               ^~~~~~~
0

$ clang++ -c bug.cpp; echo $?
clang++
bug.cpp:3:57: error: member access into incomplete type 'struct grammar'
template <typename T> void define(void) { target_grammar->derived(); }
                                                        ^
bug.cpp:1:15: note: forward declaration of 'grammar'
extern struct grammar *target_grammar;
              ^
1 error generated.
1

I read the diagnostic with "invalid use" as clearly incorrect code. Should g++
error out instead of generating a warning?

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

* [Bug c++/98306] invalid use of incomplete type 'struct grammar'
  2020-12-15 22:39 [Bug c++/98306] New: invalid use of incomplete type 'struct grammar' slyfox at gcc dot gnu.org
@ 2020-12-15 22:58 ` jakub at gcc dot gnu.org
  2020-12-18 22:17 ` slyfox at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-12-15 22:58 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
It is only a warning (pedwarn in particular, error with -pedantic-errors) in
the uninstantiated template, if you instantiate the template and the type is
still incomplete, you get hard error.

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

* [Bug c++/98306] invalid use of incomplete type 'struct grammar'
  2020-12-15 22:39 [Bug c++/98306] New: invalid use of incomplete type 'struct grammar' slyfox at gcc dot gnu.org
  2020-12-15 22:58 ` [Bug c++/98306] " jakub at gcc dot gnu.org
@ 2020-12-18 22:17 ` slyfox at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: slyfox at gcc dot gnu.org @ 2020-12-18 22:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Sergei Trofimovich <slyfox at gcc dot gnu.org> ---
That makes sense. If it's a valid C++ I'm fine with closing the bug as
RESOLVED/INVALID.

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

end of thread, other threads:[~2020-12-18 22:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-15 22:39 [Bug c++/98306] New: invalid use of incomplete type 'struct grammar' slyfox at gcc dot gnu.org
2020-12-15 22:58 ` [Bug c++/98306] " jakub at gcc dot gnu.org
2020-12-18 22:17 ` slyfox 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).