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

            Bug ID: 65799
           Summary: Allows constexpr coversion from cv void * to other
                    type
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rhainin1 at binghamton dot edu

Created attachment 35349
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35349&action=edit
minimal code to reproduce

The following code should fails to compile but instead passes:

int main() {
  static constexpr const void *vp = nullptr;
  static constexpr const char *cp = static_cast<const char*>(vp);
}
with command "g++ -std=c++14 -Wall -Wextra -pedantic -g"

As per N4140 5.19/(2.11)

(5.9/2) A conditional-expression e is a core constant expression unless the
evaluation of e, following the rules of the abstract machine (1.9), would
evaluate one of the following expressions:

(2.11) - a conversion from type cv void * to a pointer-to-object type;

Reply via email to