Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #16592

Re: variadic function

From Willem <willem@toad.stack.nl>
Newsgroups comp.lang.c
Subject Re: variadic function
Date 2012-02-01 16:15 +0000
Organization Stack Usenet News Service
Message-ID <slrnjiip8q.s1c.willem@toad.stack.nl> (permalink)
References (2 earlier) <lnaa89dory.fsf@nuthaus.mib.org> <kfnty3k9rdd.fsf@x-alumni2.alumni.caltech.edu> <lnmx9c59x8.fsf@nuthaus.mib.org> <kfnwr87z40v.fsf@x-alumni2.alumni.caltech.edu> <ln39avw19d.fsf@nuthaus.mib.org>

Show all headers | View raw


Keith Thompson wrote:
) Do you suggest that there are *realistic* cases where a call to a
) variadic function passes N arguments, and the function itself processes
) fewer than N arguments, and where this does not indicate a logical error
) in the program?

In SQL, there is a function calles 'coalesce' which returns its first
non-NULL argument.  It doesn't need to process the remaining arguments.

) I can imagine an implementation where a variadic function that
) fails to consume all its arguments might cause Bad Things To Happen.
) For example, each invocation of va_arg() might pop the corresponding
) argument off the stack; failing to do so might leave the stack in an
) inconsistent state.  It could have much the same effect as passing
) two arguments to a non-variadic function with one parameter (say,
) by casting a function pointer to an inappropriate type), which has
) undefined behavior in C as it's currently defined.

Are you sure about that?
I thought that was allowed and the second argument was simply ignored.


SaSW, Willem
-- 
Disclaimer: I am in no way responsible for any of the statements
            made in the above text. For all I know I might be
            drugged or something..
            No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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