|i think you should see the rule at C++11 184.108.40.206 paragraph 4
You are passing a function as an argument to a variadic function. That falls under the 'undefined behavior' description. This is why you get the default argument promotion.
As I said, just look it up and read the language spec.
Well, there are two things you need to look at
honey the codewitch wrote:The thing is, all the documentation you've pointed me to suggests it should be doing the same thing in both cases.
The spec clearly says that passing a function as an argument to a variadic function is undefined behavior. This is likely why you see the 'default argument promotion'.
- The rules of default argument promotion.
- The rules of passing arguments to variadic functions.
It also mentions addressable object types and register storage.
printf("%c\n",65); This is passed in a register, this is defined behavior.
printf("%c\n",foo<-1>::test());This is passed as a function. C11 220.127.116.11 paragraph 4 says this is undefined behavior.
I do see a proposal for C23 in the pipeline but it hasn't been voted on yet as far as I can tell.
I was wrong, looks like N2975 passed with 17 Yes, 0 No and two abstains.
You still haven't said what language version you are using or compiler.
modified 18-Sep-22 8:33am.