[llvm-bugs] [Bug 35651] New: Demangler produces incorrect output for alignof() and array.

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Dec 13 12:23:32 PST 2017


            Bug ID: 35651
           Summary: Demangler produces incorrect output for alignof() and
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: huangs at google.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

Please run the following:

  llvm-cxxfilt _Z3fooDTatA123_3barE

The result:

  foo(decltype(alignof (bar [123]) [123]))

The extra "[123]" at end seems wrong. Note that replacing "at" with "st" yields
correct result:

  llvm-cxxfilt _Z3fooDTstA123_3barE


  foo(decltype(sizeof (bar [123]))

This behavior is caused by code in 2 places (see ItaniumDemangle.cpp)

(1) In struct string_pair: We have 

    StrT move_full() { return std::move(first) + std::move(second); }

  this actually does not clear |first| and |second|!

(2) Compare parse_sizeof_type_expr() with parse_alignof_type(): The former has

    db.names.back() = "sizeof (" + db.names.back().move_full() + ")

  but the latter has

    db.names.back().first = "alignof (" + db.names.back().move_full() + ")";

  Therefore "st" (sizeof) overwrites |second| whereas "at" (alignof) keeps
stale |second|.

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/20171213/1cd4c366/attachment.html>

More information about the llvm-bugs mailing list