From: Daniel T. on
Gabriel Dos Reis wrote:

> Please produce a C++ program that conforms to the type system (both
> static and dynamic parts are satisfied) and yet crashes.

It can't be done, however note that it also can't be done in a
language that formally defines *all* syntax at "undefined behavior",
so I don't see how such an argument can help your position.


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Francis Glassborow on
Daniel T. wrote:
> Gabriel Dos Reis wrote:
>
>> Please produce a C++ program that conforms to the type system (both
>> static and dynamic parts are satisfied) and yet crashes.
>
> It can't be done, however note that it also can't be done in a
> language that formally defines *all* syntax at "undefined behavior",
> so I don't see how such an argument can help your position.
>
>

int foo() {
int i(0);
return foo();
}

int main(){
foo();
}


Seems correct to me but it will eventually crash on every system I know of.


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: david.boyle on
On 14 Jun, 11:44, Gabriel Dos Reis <g...(a)cs.tamu.edu> wrote:

> Please produce a C++ program that conforms to the type system (both
> static and dynamic parts are satisfied) and yet crashes.

Can we maybe agree that C++'s type-safety is analogous to a spell-
checker that doesn't alert the user to any misspellings but rather
just defines 'acceptable input' as the words contained in the Oxford
English Dictionary? :-)

Cheers,

Dave Boyle

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Gabriel Dos Reis on
"Andrei Alexandrescu (See Website For Email)" <SeeWebsiteForEmail(a)erdani.org> writes:

[...]

| At the end of the day, you must define a trusted computing base involved
| in running a program. That could fail indeed. But the point of sound
| languages is that they don't make, for the purposes of memory integrity,
| the running program a part of the TCB.

Agreed.

Getting back to the discussion, do you think that one could
meaningfully talk about C++ type safety by ignoring its dynamic component?

--
Dr. Gabriel Dos Reis (gdr(a)cs.tamu.edu), Assistant Professor
http://www.cs.tamu.edu/people/faculty/gdr
Texas A&M University -- Department of Computer Science
301, Bright Building -- College Station, TX 77843-3112

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Gabriel Dos Reis on
courpron(a)gmail.com writes:

[...]

| > So what you are saying is that in theory an ML program can't crash, but
| > in practice (which you are very found of emphasising) it can? I mean,
| > there are a number of reasons why an ML program could crash (hardware
| > bug, corruption, bad compiler) etc. so in practical real life situations
| > you can not trust your ML applications to not crash.
|
| Yes, but this is not a *type* safety issue.

agreed.

| Those situations doesn't
| follow from the ML program semantic, as this is the case when you
| dereference a null-pointer in C++ for example.

C++ does not provide a rule for dereferencing -- so, please find
another example.

| That's why I'm using the wording "practical type safety".
| I'm using the word "practical" here because the standard says that
| undefined behaviors are not correct C++ : this is the theorical side
| of UB.

It appears to me that only you seem to think of it as theoretical.
Industrial-strength compilers (e.g. very concrete stufff people use on
daily basis) use this specific aspect to build optimization passes.

Maybe it isn't 'practice vs theory' as your messages like to emphasize.

--
Dr. Gabriel Dos Reis (gdr(a)cs.tamu.edu), Assistant Professor
http://www.cs.tamu.edu/people/faculty/gdr
Texas A&M University -- Department of Computer Science
301, Bright Building -- College Station, TX 77843-3112

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]