Consider this program:

class base {
        public:
                base() {}
        private:
                int val_;
};

class derived : public base {
        public:
                derived() {}
};

template <bool> struct static_assert;
template <> struct static_assert<true> {};

int main ()
{
    static const bool x = true ? (derived*)0 : (base*)0;
    static_assert<!x> test;
}

I'm expecting it to compile (EDG compiles it).  The current error I get is:

error: 'x' cannot appear in a constant-expression

If I allow run time evaluation of x, and print it out, I get 1 instead of 0 as
I expect.


-- 
           Summary: conditional operator operating on derived / base
                    pointers appears incorrect
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hhinnant at apple dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25894

Reply via email to