Re: Cracking DES with C++ is faster than Java?
From: Claudio Puviani (puviani_at_hotmail.com)
Date: 05/06/04
- Next message: privacy.at Anonymous Remailer: "will be added to the message in lieu of the standard From header."
- Previous message: privacy.at Anonymous Remailer: "A carriage return (CRLF)"
- In reply to: newstome_at_comcast.net: "Re: Cracking DES with C++ is faster than Java?"
- Next in thread: newstome_at_comcast.net: "Re: Cracking DES with C++ is faster than Java?"
- Reply: newstome_at_comcast.net: "Re: Cracking DES with C++ is faster than Java?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Thu, 06 May 2004 05:28:19 GMT
<newstome@comcast.net> wrote
> In sci.crypt Douglas A. Gwyn <DAGwyn@null.net> wrote:
> > A. Lloyd Flanagan wrote:
> >> Perhaps, but the statement was that it wasn't "safe" to compile C code
> >> with a C++ compiler.
> >
> > And I gave examples of that.
>
> I just looked back through this thread, and couldn't find any posting
> from you giving such an example. I'm honestly curious: can you post
> an example of something that is valid C and C++, but works differently
> in the two languages? (I think that's what you're saying is possible.)
I know this wasn't addressed to me, but I'm sure you don't care who gives you the
examples.
First example: sizeof('x') == sizeof(int) in C but in C++ sizeof('x') ==
sizeof(char). Therefore, any code that uses the value of sizeof('x') will behave
differently under the two languages. This is because 'x' is of type int in C but
of type char in C++.
Here's another snippet, adapted from appendix C of the C++ Standard:
char a[100];
printf("%d\n", sizeof(0, a));
This will print 100 in C++ but it will print the value of sizeof(char *) in C.
The reason is that in C, the comma operator returns and r-value, but in C++, it
returns an l-value.
And another example adapted from that same appendix:
int x[99];
void f()
{
struct x { int a; };
printf("%d\n", sizeof(x));
}
This will print the size of the array in C, but in C++, it will print the size of
the struct. The reason for this difference is that C++ introduces the name of the
struct at the function scope thereby hiding the array. In C, the tag, 'x', has
no visibility past the declaration.
Granted, these are contrived examples, but the aim was to show differences, not
real-life code. I'm sure someone could find more examples.
Claudio Puviani
- Next message: privacy.at Anonymous Remailer: "will be added to the message in lieu of the standard From header."
- Previous message: privacy.at Anonymous Remailer: "A carriage return (CRLF)"
- In reply to: newstome_at_comcast.net: "Re: Cracking DES with C++ is faster than Java?"
- Next in thread: newstome_at_comcast.net: "Re: Cracking DES with C++ is faster than Java?"
- Reply: newstome_at_comcast.net: "Re: Cracking DES with C++ is faster than Java?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|