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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code,
                   |                            |wrong-code
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
            Summary|Using a std::string passed  |[14/15 Regression] Using a
                   |to a virtual member         |std::string passed to a
                   |function of a side-casted   |virtual member function of
                   |pointer spuriously triggers |a side-casted pointer
                   |UBSan on 14.2.0, and ICEs   |spuriously ICEs (wrong code
                   |on trunk                    |with checking disable)
   Target Milestone|---                         |14.3
   Last reconfirmed|                            |2024-09-02

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. The ICE happens also with -fchecking which I had expected.

I moved the classes into an anonymous namespace instead of being local to the
function and we still get the ICE:
```
#include <string>
namespace {
    struct VirtualBase {
      virtual ~VirtualBase() {}
    };
    struct VirtualBase2 {
      virtual void foo(std::string s) const = 0;
    };
    struct MultiBase : VirtualBase, VirtualBase2 {
      void foo(std::string s) const override {
        (void)s.find("X");
      }
    } multibase{};
}
int main()
{
    VirtualBase* p{&multibase};
    dynamic_cast<VirtualBase2*>(p)->foo("Y");
}
```

I have not reduced it further yet.

Reply via email to