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

--- Comment #7 from Halalaluyafail3 <luigighiron at gmail dot com> ---
(In reply to Drea Pinski from comment #6)
> >Note that the call to foo is never actually reached, so the undefined 
> >behavior does not happen.
> 
> Yes but isn't that is the same as doing:
> ```
> int f();
> 
> int g()
> {
>   f();
> }
> 
> int main()
> {
>   return 0;
> }
> ```
> 
> The undefined behavior is not reached here either.
f is odr-used here, so it will be IFNDR. But since foo in the original example
is a pure virtual function and the call is not using an explicitly qualified
name, A::foo is not named by the expression foo(). If it was not like this
then:

struct C{
    virtual void bar()=0;
    void baz(){
        bar();
    }
};

Would be invalid without a definition of C::bar. The original example is doing
the same thing as this, just inside of the constructor.

Reply via email to