[llvm-bugs] [Bug 42296] New: Identity addrspacecast's are thrown with asserts enabled.

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jun 17 00:46:16 PDT 2019


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: unassignedclangbugs at nondot.org
          Reporter: alex.davies at iinet.net.au
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190617/d0afecc8/attachment.html>


More information about the llvm-bugs mailing list