Skip to content

CWG2887 [diff.cpp03.expr] Should we list the behavioral change of typeid in C++11 due to N3055? #6861

Closed
@frederick-vs-ja

Description

@frederick-vs-ja

In the following example, the operand of typeid (an xvalue of a polymorphic class type) wasn't evaluated in C++98, but was made to evaluated since C++11 due to N3055.

#include <typeinfo>
#include <cstdio>

struct B {
  virtual ~B() { std::puts("~B"); }
};

struct D : B {};

struct WrapB {
  B b;
};

struct WrapD {
  D d;
};

int main() {
  typeid(true ? WrapB().b : WrapD().d);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions