Explicitly forbid dynamic_cast

After discussion on webrtc-core, this option is still thought to be
a Bad Idea in webrtc.

Bug: none
Change-Id: I15d0a6f7d6489b8bf37c1dfa31572139c9b85753
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/281881
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38555}
This commit is contained in:
Harald Alvestrand 2022-11-04 12:13:04 +00:00 committed by WebRTC LUCI CQ
parent dd34a482d9
commit f88487c5c9

View file

@ -173,6 +173,16 @@ headers you need.
[goog-forward-declarations]: https://google.github.io/styleguide/cppguide.html#Forward_Declarations [goog-forward-declarations]: https://google.github.io/styleguide/cppguide.html#Forward_Declarations
### RTTI and dynamic_cast
The Google style guide [permits the use of dynamic_cast](https://google.github.io/styleguide/cppguide.html#Run-Time_Type_Information__RTTI_).
However, WebRTC does not permit it. WebRTC (and Chrome) is compiled with the
-fno-rtti flag, and the overhead of enabling RTTI it is on the order of 220
Kbytes (for Android Arm64).
Use static_cast and take your own steps to ensure type safety.
## C ## C
There's a substantial chunk of legacy C code in WebRTC, and a lot of it is old There's a substantial chunk of legacy C code in WebRTC, and a lot of it is old