Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: variadic function |
| Date | 2012-03-08 13:57 -0800 |
| Organization | None to speak of |
| Message-ID | <lnhaxy4uy9.fsf@nuthaus.mib.org> (permalink) |
| References | (3 earlier) <kfnty3k9rdd.fsf@x-alumni2.alumni.caltech.edu> <lnmx9c59x8.fsf@nuthaus.mib.org> <kfnwr87z40v.fsf@x-alumni2.alumni.caltech.edu> <ln39avw19d.fsf@nuthaus.mib.org> <kfn399jt06x.fsf@x-alumni2.alumni.caltech.edu> |
Tim Rentsch <txr@alumni.caltech.edu> writes:
> Keith Thompson <kst-u@mib.org> writes:
[...]
>> When C was standardized in 1989, it *could have* been defined so that
>> excess arguments cause undefined behavior. If it had, I don't believe
>> it would have caused any great inconvenience. (Changing it now *would*
>> cause great inconvenience.)
>
> I believe behavior with printf(), etc, predates the first
> C standard by at least a decade. At that time (ie, the
> late 1970's or earlier) there was no notion of undefined
> behavior - implementations just did what they did. So
> what you're suggesting doesn't really make sense, historically.
The first C standard introduced the rule that calling printf() without a
proper declaration in scope has undefined behavior. Prior to that, this
program:
extern printf();
main() { printf("Hello, world\n"); }
would have been well behaved (i.e., would print "Hello, world" under
most or all implementations).
The standard imposed a *lot* of restrictions that rendered the behavior
of some existing code undefined -- including, if I'm not mistaken, the
first "hello, world" program in K&R1 (I don't remember whether it had
"#include <stdio.h>" or not).
Adding a rule that calling printf() with excess arguments has undefined
behavior would have been consistent with that.
I'm not saying it would necessarily have been a good idea to impose such
a rule, but it wouldn't have been completely insane.
[...]
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
variadic function Quentin Pope <qp19433@hotmail.NOSPAM.com> - 2011-11-05 22:32 +0000
Re: variadic function Keith Thompson <kst-u@mib.org> - 2011-11-05 15:50 -0700
Re: variadic function Quentin Pope <qp19433@hotmail.NOSPAM.com> - 2011-11-07 17:41 +0000
Re: variadic function James Kuyper <jameskuyper@verizon.net> - 2011-11-05 18:53 -0400
Re: variadic function Keith Thompson <kst-u@mib.org> - 2011-11-05 16:35 -0700
Re: variadic function Kaz Kylheku <kaz@kylheku.com> - 2011-11-06 01:36 +0000
Re: variadic function Kaz Kylheku <kaz@kylheku.com> - 2011-11-06 01:31 +0000
Re: variadic function Barry Schwarz <schwarzb@dqel.com> - 2011-11-06 09:45 -0800
Re: variadic function Keith Thompson <kst-u@mib.org> - 2011-11-06 11:38 -0800
Re: variadic function Tim Rentsch <txr@alumni.caltech.edu> - 2012-01-24 23:24 -0800
Re: variadic function Keith Thompson <kst-u@mib.org> - 2012-01-25 02:54 -0800
Re: variadic function Tim Rentsch <txr@alumni.caltech.edu> - 2012-01-31 18:22 -0800
Re: variadic function Keith Thompson <kst-u@mib.org> - 2012-01-31 21:50 -0800
Re: variadic function James Kuyper <jameskuyper@verizon.net> - 2012-02-01 07:55 -0500
Re: variadic function Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-02-01 08:06 -0500
Re: variadic function Keith Thompson <kst-u@mib.org> - 2012-02-01 11:42 -0800
Re: variadic function Willem <willem@toad.stack.nl> - 2012-02-01 16:15 +0000
Re: variadic function Keith Thompson <kst-u@mib.org> - 2012-02-01 11:41 -0800
Re: variadic function Shao Miller <sha0.miller@gmail.com> - 2012-02-01 13:41 -0500
Re: variadic function blp@cs.stanford.edu (Ben Pfaff) - 2012-02-01 10:45 -0800
Re: variadic function Tim Rentsch <txr@alumni.caltech.edu> - 2012-03-08 10:30 -0800
Re: variadic function Keith Thompson <kst-u@mib.org> - 2012-03-08 13:57 -0800
Re: variadic function Tim Rentsch <txr@alumni.caltech.edu> - 2012-03-09 13:10 -0800
Re: variadic function jgk@panix.com (Joe keane) - 2012-03-11 07:56 +0000
Re: variadic function Tim Rentsch <txr@alumni.caltech.edu> - 2012-03-11 13:01 -0700
Re: variadic function jgk@panix.com (Joe keane) - 2012-03-12 19:04 +0000
Re: variadic function Tim Rentsch <txr@alumni.caltech.edu> - 2012-03-13 15:05 -0700
csiph-web