Throwing an exception here does not make much sense, the
CRYPTO_COMPILE_ASSERT is there to assert the condition _at compile time_,
throwing an exception delays the error until runtime.
The unused code warning is probably generated by the way the compiletime
assert is made, but that doesn't mean that it can be removed.

Richard Peters

----- Original Message ----- 
From: "Stephen torri" <[EMAIL PROTECTED]>
To: "cryptopp" <[EMAIL PROTECTED]>
Sent: Monday, November 03, 2003 07:02
Subject: [PATCH] cast.cpp - aggregate has a partly bracketed initializer

The assert statement is reported as being unused. This was test both
with the compiler flags set to '-g' and '-O2'.

Stephen

Index: algparam.h
===================================================================
RCS file: /cvsroot/cryptopp/c5/algparam.h,v
retrieving revision 1.6
diff -U2 -r1.6 algparam.h
--- algparam.h 18 Jul 2003 04:35:30 -0000 1.6
+++ algparam.h 3 Nov 2003 05:21:05 -0000
@@ -24,6 +24,14 @@
  template <class T> ConstByteArrayParameter(const T &string, bool
deepCopy = false)
  {
-  CRYPTOPP_COMPILE_ASSERT(sizeof(string[0])==1);
-  Assign((const byte *)string.data(), string.size(), deepCopy);
+   /* FIXME: Unused -
+      CRYPTOPP_COMPILE_ASSERT(sizeof(string[0])==1);
+
+      SUGGESTION: Consider throwing an exception here to allow the
+      program to exit gracefully and be more informative. Without
+      an exception a programmer needs to use a stack trace via a
+      core dump to figure out why crypto++ or their application
+      caused this condition to be true
+   */
+   Assign((const byte *)string.data(), string.size(), deepCopy);
  }

@@ -279,7 +287,8 @@
  virtual const NameValuePairs & GetParent() const =0;

+ const char *m_name;
  bool m_throwIfNotUsed;
  mutable bool m_used;
- const char *m_name;
+
 };


--
Stephen Torri
GPG Key: http://www.cs.wustl.edu/~storri/storri.asc


Reply via email to