Board index » cppbuilder » Re: char* literal strings are the devil's work...

Re: char* literal strings are the devil's work...


2007-11-16 05:00:57 PM
cppbuilder27
Alisdair Meredith[CodeGear] < XXXX@XXXXX.COM >wrote:
Quote
Hendrik Schober wrote:

>The only ways to make a type in C++ is to use either
>'class', 'struct', 'union', or 'enum'.
>(Did I forget one?

arrays, functions, pointers, pointer-to-members and references are all
user-defined types too.
Ah. I didn't think of modified types.
+10 points to Alisdair.
Schobi
--
XXXX@XXXXX.COM is never read
I'm HSchober at gmx dot de
"A patched buffer overflow doesn't mean that there's one less way attackers
can get into your system; it means that your design process was so lousy
that it permitted buffer overflows, and there are probably thousands more
lurking in your code."
Bruce Schneier
 
 

Re:Re: char* literal strings are the devil's work...

Ed Mulroy [TeamB] < XXXX@XXXXX.COM >wrote:
Quote
>Hendrik Schober wrote in message news:473cc6b9$ XXXX@XXXXX.COM ...
>
>>I have made a type.
>
>The only ways to make a type in C++ is to use either
>'class', 'struct', 'union', or 'enum'.
>(Did I forget one?

typedef
You lose.
An old fart as you should have known better. <shakes head>
Quote
. Ed
Schobi
--
XXXX@XXXXX.COM is never read
I'm HSchober at gmx dot de
"A patched buffer overflow doesn't mean that there's one less way attackers
can get into your system; it means that your design process was so lousy
that it permitted buffer overflows, and there are probably thousands more
lurking in your code."
Bruce Schneier
 

Re:Re: char* literal strings are the devil's work...

It is a consequence of my good English! I meant a typo. :)
Vladimir Grigoriev
"Hendrik Schober" < XXXX@XXXXX.COM >wrote in message
Quote
Vladimir Grigoriev < XXXX@XXXXX.COM >wrote:
>I have made a type.

The only ways to make a type in C++ is to use either
'class', 'struct', 'union', or 'enum'.
(Did I forget one?

>[...]
>Vladimir Grigoriev

SCNRobi

--
XXXX@XXXXX.COM is never read
I'm HSchober at gmx dot de
"A patched buffer overflow doesn't mean that there's one less way
attackers
can get into your system; it means that your design process was so lousy
that it permitted buffer overflows, and there are probably thousands more
lurking in your code."
Bruce Schneier

 

{smallsort}

Re:Re: char* literal strings are the devil's work...

Vladimir Grigoriev < XXXX@XXXXX.COM >wrote:
Quote
It is a consequence of my good English! I meant a typo. :)
I know. But admitting that would have spoiled the fun.
(Also, I wouldn't have had a chance to get educated by
Alisdair.)
Quote
Vladimir Grigoriev
[...]
Schobi
--
XXXX@XXXXX.COM is never read
I'm HSchober at gmx dot de
"A patched buffer overflow doesn't mean that there's one less way attackers
can get into your system; it means that your design process was so lousy
that it permitted buffer overflows, and there are probably thousands more
lurking in your code."
Bruce Schneier
 

Re:Re: char* literal strings are the devil's work...

Alisdair Meredith[CodeGear] < XXXX@XXXXX.COM >wrote:
Quote
Hendrik Schober wrote:

>>[The problem is to warn that a reference with static duration to an
>>object with a scoped lifetime]
>
>I run into a parse error on this one.

The problem is [...]
Thnaks. I still can't parse the first one, but now I
think I know what you mean.
Schobi
--
XXXX@XXXXX.COM is never read
I'm HSchober at gmx dot de
"A patched buffer overflow doesn't mean that there's one less way attackers
can get into your system; it means that your design process was so lousy
that it permitted buffer overflows, and there are probably thousands more
lurking in your code."
Bruce Schneier
 

Re:Re: char* literal strings are the devil's work...

Quote
You lose.
An old fart as you should have known better. <shakes head>
Perfection is elusive but I will continue to try.
As for being "an old fart" - I might have avoided it but the alternative was
not attractive. <g>
. Ed
Quote
Hendrik Schober wrote in message
news: XXXX@XXXXX.COM ...

>>>I have made a type.
>>
>>The only ways to make a type in C++ is to use either
>>'class', 'struct', 'union', or 'enum'.
>>(Did I forget one?
>
>typedef

You lose.
An old fart as you should have known better. <shakes head>
 

Re:Re: char* literal strings are the devil's work...

Ed Mulroy [TeamB] < XXXX@XXXXX.COM >wrote:
Quote
>Hendrik Schober wrote in message
>news: XXXX@XXXXX.COM ...
>
>>>>I have made a type.
>>>
>>>The only ways to make a type in C++ is to use either
>>>'class', 'struct', 'union', or 'enum'.
>>>(Did I forget one?
>>
>>typedef
>
>You lose.
>An old fart as you should have known better. <shakes head>

Perfection is elusive but I will continue to try.
Just as with the right way to quote, yes? :^>
Quote
As for being "an old fart" - I might have avoided it but the alternative was
not attractive. <g>
:o>
Quote
. Ed
Schobi
--
XXXX@XXXXX.COM is never read
I'm HSchober at gmx dot de
"A patched buffer overflow doesn't mean that there's one less way attackers
can get into your system; it means that your design process was so lousy
that it permitted buffer overflows, and there are probably thousands more
lurking in your code."
Bruce Schneier
 

Re:Re: char* literal strings are the devil's work...

"Alisdair Meredith[CodeGear]" < XXXX@XXXXX.COM >writes:
Quote
Hendrik Schober wrote:

>>[The problem is to warn that a reference with static duration to an
>>object with a scoped lifetime]
>
>I run into a parse error on this one.

The problem is a static duration reference has a lifetime extending to
the end of the program. If it is bound to an object with a more
deterministic lifetime (local scope, or dynamic allocation) then there
is a strong risk of holding a reference to a non-existant object. The
big risk here is when a function accepts an argument by reference, and
binds that to a locally scoped static duration reference. There is no
way to identify at the call point that the object must also be static
duration, and no way inside the function to know it is called 'safely'.
I wouldn't say there is "no way", since you are the compiler and you
can see things mortals cannot. For example, if the function that is
being called is defined in the same translation unit of the code, then
it can take a peek inside. So there are at least special cases where
it can easily be done.
To know that an extern function is returning a reference, there will
have to be a lot of intelligence added to the compiler and linker,
with decorated function meta-information in the .obj, and the linker
reading that information and reacting. It'd almost be a interpreted
language running at compile time, between the compiler and linker.
A function call that needs the linker to resolve can have additional
information, like a declared dependency on the called function having
a return value of static duration. The function definition can have
decorating meta-data describing attributes of the function, including
the duration of the return value (if known.) If it cannot be
determined, then the dependency fails and a warning should be
generated, etc.
Possible, but hard. :)
--
Chris (TeamB);