public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114163] New: Calling member function of an incomplete type compiles in gcc and does not compile in clang and msvc
@ 2024-02-29  9:23 jlame646 at gmail dot com
  2024-02-29 11:59 ` [Bug c++/114163] " harald at gigawatt dot nl
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: jlame646 at gmail dot com @ 2024-02-29  9:23 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114163
           Summary: Calling member function of an incomplete type compiles
                    in gcc and does not compile in clang and msvc
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jlame646 at gmail dot com
  Target Milestone: ---

The following invalid program(since lambda's body in not complete class
context) is compiled by gcc:

```
struct TestClass {
  void testFinction() {}
  static TestClass* ptr_;
  constexpr static auto funcPtr = +[](){ ptr_->testFinction(); };
};

TestClass* TestClass::ptr_ = new TestClass();

int main() {
//   TestClass::funcPtr();
//   delete TestClass::ptr_;
  return 0;
}
```
Demo https://godbolt.org/z/Yhc8MeWW6

First discovered at
https://stackoverflow.com/questions/78080083/calling-member-function-of-an-incomplete-type-compiles-in-gcc-and-does-not-compi

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

* [Bug c++/114163] Calling member function of an incomplete type compiles in gcc and does not compile in clang and msvc
  2024-02-29  9:23 [Bug c++/114163] New: Calling member function of an incomplete type compiles in gcc and does not compile in clang and msvc jlame646 at gmail dot com
@ 2024-02-29 11:59 ` harald at gigawatt dot nl
  2024-02-29 12:13 ` de34 at live dot cn
  2024-02-29 12:15 ` jakub at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: harald at gigawatt dot nl @ 2024-02-29 11:59 UTC (permalink / raw)
  To: gcc-bugs

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

Harald van Dijk <harald at gigawatt dot nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |harald at gigawatt dot nl

--- Comment #1 from Harald van Dijk <harald at gigawatt dot nl> ---
You may be right that the class is not complete at that point but there is no
requirement for the class to be complete. CWG1836 changed that to "In both
cases, the class type shall be complete unless the class member access appears
in the definition of that class." Here, the class member access does appear in
the definition of the class, so it's okay that the class is incomplete.

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

* [Bug c++/114163] Calling member function of an incomplete type compiles in gcc and does not compile in clang and msvc
  2024-02-29  9:23 [Bug c++/114163] New: Calling member function of an incomplete type compiles in gcc and does not compile in clang and msvc jlame646 at gmail dot com
  2024-02-29 11:59 ` [Bug c++/114163] " harald at gigawatt dot nl
@ 2024-02-29 12:13 ` de34 at live dot cn
  2024-02-29 12:15 ` jakub at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: de34 at live dot cn @ 2024-02-29 12:13 UTC (permalink / raw)
  To: gcc-bugs

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

Jiang An <de34 at live dot cn> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |de34 at live dot cn

--- Comment #2 from Jiang An <de34 at live dot cn> ---
May be related to CWG2852.
https://cplusplus.github.io/CWG/issues/2852.html

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

* [Bug c++/114163] Calling member function of an incomplete type compiles in gcc and does not compile in clang and msvc
  2024-02-29  9:23 [Bug c++/114163] New: Calling member function of an incomplete type compiles in gcc and does not compile in clang and msvc jlame646 at gmail dot com
  2024-02-29 11:59 ` [Bug c++/114163] " harald at gigawatt dot nl
  2024-02-29 12:13 ` de34 at live dot cn
@ 2024-02-29 12:15 ` jakub at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-29 12:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
https://wg21.link/CWG1836
https://eel.is/c++draft/expr.ref#4

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

end of thread, other threads:[~2024-02-29 12:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-29  9:23 [Bug c++/114163] New: Calling member function of an incomplete type compiles in gcc and does not compile in clang and msvc jlame646 at gmail dot com
2024-02-29 11:59 ` [Bug c++/114163] " harald at gigawatt dot nl
2024-02-29 12:13 ` de34 at live dot cn
2024-02-29 12:15 ` jakub 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).