Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

std::any_cast may throw even when type seems to be right #37459

Open Quuxplusone opened 6 years ago

Quuxplusone commented 6 years ago
Bugzilla Link PR38485
Status NEW
Importance P normal
Reported by Michał Walenciak (kicer86@gmail.com)
Reported on 2018-08-08 07:10:58 -0700
Last modified on 2020-10-06 17:52:03 -0700
Version 6.0
Hardware PC Linux
CC dgregor@apple.com, llvm-bugs@lists.llvm.org, scpeters@openrobotics.org
Fixed by commit(s)
Attachments std_any.tar.gz (1096 bytes, application/gzip)
Blocks
Blocked by
See also
Created attachment 20656
example

I've prepared a single example which throws std::bad_any_cast.

At first glance it should work (no problems with gcc).
Quuxplusone commented 6 years ago

Attached std_any.tar.gz (1096 bytes, application/gzip): example

Quuxplusone commented 6 years ago

I've run into this same problem; thanks for reporting it and providing the reproducible example. I've tested the example with clang6 and gcc8 on bionic, and only clang exhibits the problem. Furthermore, if I modify the example to use boost::any instead of std::any, then it still works with clang. It seems to be an issue with clang std::any.

Quuxplusone commented 6 years ago
Here's the issue report for my downstream code affected by this bug:
https://bitbucket.org/osrf/sdformat/issues/202/bad_any_cast-after-element-getany-with
Quuxplusone commented 6 years ago

Should the Component be re-categorized as C++17?

Quuxplusone commented 5 years ago

I just reproduced this bug with the Xcode 11 GM on macOS Catalina beta.

Quuxplusone commented 4 years ago

I just tested again with Apple clang version 11.0.3 (clang-1103.0.32.62) on macOS 10.15.7, and I'm not able to reproduce the problem. So, I guess it has been fixed?