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}
diff --git a/g3doc/style-guide.md b/g3doc/style-guide.md index 9d713c6..44c7521 100644 --- a/g3doc/style-guide.md +++ b/g3doc/style-guide.md
@@ -173,6 +173,16 @@ [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 There's a substantial chunk of legacy C code in WebRTC, and a lot of it is old