public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100209] New: multiple inheritance with crtp pattern fails on sequentioal member access
@ 2021-04-22 12:48 autumn.rain at mail dot ru
  2021-04-22 13:14 ` [Bug c++/100209] " rguenth at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: autumn.rain at mail dot ru @ 2021-04-22 12:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100209
           Summary: multiple inheritance with crtp pattern fails on
                    sequentioal member access
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: autumn.rain at mail dot ru
  Target Milestone: ---

If multiple inheritance is used with CRTP pattern in a constexpr context,
resulting class is failed to create.
When deriving AB from a single class (also with mani accessors) the constexpr
context is working well.
The error is reproduced on gcc since 6.1.x on any platform.


D:\>D:\0W\00Tools\2GCC_10.2_2020q4\bin\arm-none-eabi-g++ -Wall D:\Test.cpp
D:\Test.cpp:26:60: error: '*(const __ab_t*)(&(&
__ab_t().__ab_t::<anonymous>.__a
_t<__ab_t>::SetA(100))->__ab_t::<anonymous>.__b_t<__ab_t>::SetB(10))' is not a
c
onstant expression
   26 | static constexpr const auto AB = __ab_t().SetA(100).SetB(10);
      |                                                            ^

gcc version
10.2.1 

template<typename TDERIVED>
struct __a_t
{
       unsigned char A = 0;
       constexpr TDERIVED & SetA(const unsigned char & value) { A = value;  
return *static_cast<TDERIVED *>(this); }

       constexpr __a_t() {}
};

template<typename TDERIVED>
struct __b_t
{
       unsigned char B = 0;
       constexpr TDERIVED & SetB(const unsigned char & value) { B = value;
return *static_cast<TDERIVED *>(this); }

       constexpr __b_t() {}
};

class __ab_t: public __a_t<__ab_t>, public __b_t<__ab_t>
{
    public:
        constexpr __ab_t(){}

};

static constexpr const auto AB = __ab_t().SetA(100).SetB(10);

int A = 0;

int main()
{
    A = AB.A;
}

How-To-Repeat:
Compile the attached code

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

end of thread, other threads:[~2021-11-06 23:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-22 12:48 [Bug c++/100209] New: multiple inheritance with crtp pattern fails on sequentioal member access autumn.rain at mail dot ru
2021-04-22 13:14 ` [Bug c++/100209] " rguenth at gcc dot gnu.org
2021-04-23  2:51 ` ppalka at gcc dot gnu.org
2021-04-23  4:28 ` ppalka at gcc dot gnu.org
2021-04-23  4:29 ` ppalka at gcc dot gnu.org
2021-04-26 21:31 ` cvs-commit at gcc dot gnu.org
2021-04-28  2:34 ` ppalka at gcc dot gnu.org
2021-11-06 23:40 ` ppalka 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).