From f88487c5c94e19fa984ce52965598c24ac3706c7 Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Fri, 4 Nov 2022 12:13:04 +0000 Subject: [PATCH] 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 Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#38555} --- g3doc/style-guide.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/g3doc/style-guide.md b/g3doc/style-guide.md index 9d713c68c9..44c752173b 100644 --- a/g3doc/style-guide.md +++ b/g3doc/style-guide.md @@ -173,6 +173,16 @@ headers you need. [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