llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.4k stars 11.74k forks source link

Clang++ errors when using `va_start` in a lambda with variadic arguments #19991

Open llvmbot opened 10 years ago

llvmbot commented 10 years ago
Bugzilla Link 19617
Version trunk
OS MacOS X
Attachments Program that causes the issue described in this ticket
Reporter LLVM Bugzilla Contributor
CC @asl,@DougGregor,@vadz

Extended Description

Overview

Clang will error out if va_start is used from a lambda with C-style variadic arguments, unless the parent function also has variadic arguments.

Steps to reproduce

Compile attached file.

Expected result

Program should (probably?) compile and return 88 on execution.

Actual result

Clang errors out:

    test.cpp:8:3: error: 'va_start' used in function with fixed args
                va_start(ap, a);

Additional information

I'm not a language lawyer, so I'm not sure if lambdas with variadic arguments are allowed. However, I'm pretty confident that either lambdas with variadic arguments should always cause an error (including when the parent function also has variadic parameters), or that they should work on their own.

g++ 4.8.1 seems to accept lambdas with variadic arguments (or at least accepts the attached program).

vadz commented 7 years ago

FWIW this bug is still present in Apple LLVM version 8.0.0 (clang-800.0.42.1).