Movatterモバイル変換


[0]ホーム

URL:


Issue 2247 - WG21 CWG Issues
Title
Lambda capture and variable argument list
Status
c++17
Section
7.5.6.3 [expr.prim.lambda.capture]
Submitter
Aaron Ballman

Created on2016-03-11.00:00:00 last changed96 months ago

Messages

msg6158 (view)
Date: 2017-02-15.00:00:00

Proposed resolution (February, 2017):

Change 17.14.2 [cstdarg.syn] paragraph 1 as follows:

The contents of the header<cstdarg> are the same as the Cstandard library header<stdarg.h>, with the followingchanges: The restrictions that ISO C places on the second parameter totheva_start() macro in header<stdarg.h> aredifferent in this International Standard. The parameterparmN isthe identifier of the rightmost parameter in the variableparameter list of the function definition (the one just beforethe... ).223If the parameterparmN is a pack expansion (13.7.4 [temp.variadic]) or anentity resulting from a lambda capture (7.5.6 [expr.prim.lambda]), theprogram is ill-formed, no diagnostic required. If theparameterparmN is of a reference type, or of a type that is notcompatible with the type that results when passing an argument for whichthere is no parameter, the behavior is undefined.
msg5773 (view)
Date: 2016-12-15.00:00:00

Notes from the December, 2016 teleconference:

Such examples should have undefined behavior;va_startshould only be permitted to access the arguments for the currentfunction.

msg5772 (view)
Date: 2017-02-15.00:00:00

[Adopted at the February/March, 2017 meeting.]

Consider:

  #include <cstdarg>  #include <iostream>  auto f(int i, ...) {   return [&]() {    va_list l;    va_start(l, i);    std::cout << "i = " << i << ", " << va_arg(l, int) << std::endl;    va_end(l);   };  }  int main() {   auto l = f(100, 42);   l();  }

Is this defined behavior, accessing the variadic arguments passedtof?

History
DateUserActionArgs
2018-02-27 00:00:00adminsetmessages: +msg6158
2018-02-27 00:00:00adminsetstatus: open -> c++17
2017-02-06 00:00:00adminsetmessages: +msg5773
2016-03-11 00:00:00admincreate

[8]ページ先頭

©2009-2026 Movatter.jp