https://bugs.llvm.org/show_bug.cgi?id=42296

            Bug ID: 42296
           Summary: Identity addrspacecast's are thrown with asserts
                    enabled.
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: alex.dav...@iinet.net.au
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org,
                    neeil...@live.com, richard-l...@metafoo.co.uk

CastInst::castIsValid returns false for addrspacecasts from/to the same space,
triggering an assertion failure in clang debug builds:

  assert(CastInst::castIsValid(opc, C, Ty) && "Invalid constantexpr cast!");

A simple test case:

  static int x;
  return *(unsigned char __attribute__((address_space(0))) *)&x;

Which should blow up on any system with asserts enabled. Note, casting to a
different type is required to reproduce the error, as otherwise clang
simplifies the cast away.

With assertions disabled, the code compiles, however the identity addrspacecast
is emitted and probably should not be.

Note: address_space(0) is used only as an example here, the assertion will fail
whenever the value and cast are in the same space.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to