Skip to content

offsetof() is not constant in clang-cl #59689

@danakj

Description

@danakj

I use offsetof in a template parameter, this works on all compilers (Clang, MSVC, GCC) except clang-cl.

error: non-type template argument is not a constant expression

C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\stddef.h(47,31): note: 
      expanded from macro 'offsetof'
  ...offsetof(s,m) ((::size_t)&reinterpret_cast<char const volatile&>((((s*)0)->m)))    
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    

Obviously reinterpret_cast is not constant evaluable. So I guess MSVC provides a builtin, but clang-cl does not?

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang-cl`clang-cl` driver. Don't use for other compiler parts

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions