"Strong typing vs. strong testing"

Seebs usenet-nospam at seebs.net
Thu Sep 30 18:03:29 CEST 2010

On 2010-09-30, Paul Rubin <no.email at nospam.invalid> wrote:
>     int maximum(int a, int b);
>     int foo() {
>       int (*barf)() = maximum;
>       return barf(3);
>     }

> This compiles fine for me.  Where is the cast?

On the first line of code inside foo().

> Where is the error message?

You chose to use a form that suppresses the error message.

> Are you saying barf(3) doesn't call maximum?

I would say that it is undefined whether or not it calls maximum, because
you called a function through a function pointer of a different sort,
which invoked undefined behavior.

There exist real compiles on which code much like this will coredump
without ever once trying to jump to the address of the maximum function,
because the compiler caught your error.

Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nospam at seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.

More information about the Python-list mailing list