Bug 1077887: Work around old GCC "enum class" bug, r=mmc
☠☠ backed out by bca6ee8bf3ff ☠ ☠
authorBrian Smith <brian@briansmith.org>
Sat, 04 Oct 2014 18:45:31 -0700
changeset 232339 16fe1b9eb9e6f66d787cbcc72cdfa5328f08f6fa
parent 232338 76000f9f12dac768085ef3370c4717bb4178cf11
child 232340 124b04c01c7127593f89408edf82db7e22122735
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1077887: Work around old GCC "enum class" bug, r=mmc
--- a/security/pkix/include/pkix/Result.h
+++ b/security/pkix/include/pkix/Result.h
@@ -144,20 +144,20 @@ MOZILLA_PKIX_ENUM_CLASS Result
 // Returns the stringified name of the given result, e.g. "Result::Success",
 // or nullptr if result is unknown (invalid).
 const char* MapResultToName(Result result);
 // We write many comparisons as (x != Success), and this shortened name makes
 // those comparisons clearer, especially because the shortened name often
 // results in less line wrapping.
-// Visual Studio before VS2013 does not support "enum class," so
-// Result::Success will already be visible in this scope, and compilation will
-// fail if we try to define a variable with that name here.
-#if !defined(_MSC_VER) || (_MSC_VER >= 1700)
+// If MOZILLA_PKIX_ENUM_CLASS doesn't expand to "enum class" then
+// Result::Success will already be in scope, and compilation would fail if we
+// were to try to define a variable named "Success" here.
 static const Result Success = Result::Success;
 inline bool
 IsFatalError(Result rv)
   return (static_cast<unsigned int>(rv) & FATAL_ERROR_FLAG) != 0;
--- a/security/pkix/include/pkix/enumclass.h
+++ b/security/pkix/include/pkix/enumclass.h
@@ -17,26 +17,28 @@
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
-// Work around missing std::bind, std::ref, std::cref in older compilers. This
-// implementation isn't intended to be complete; rather, it is the minimal
-// implementation needed to make our use of std::bind work.
 #ifndef mozilla_pkix__enumclass_h
 #define mozilla_pkix__enumclass_h
 #if defined(_MSC_VER) && (_MSC_VER < 1700)
 // Microsoft added support for "enum class" in Visual C++ 2012. Before that,
 // Visual C++ has supported typed enums for longer than that, but using typed
 // enums results in C4480: nonstandard extension used: specifying underlying
 // type for enum.
 #define MOZILLA_PKIX_ENUM_CLASS  __pragma(warning(suppress: 4480)) enum
+#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 407)
+// GCC before version 4.7 may crash when compiling code that static_casts a
+// value of scoped typed enum type. See
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48106.
 #define MOZILLA_PKIX_ENUM_CLASS enum class
 #endif // mozilla_pkix__enumclass_h