Cannot check function address

Steven Schveighoffer schveiguy at gmail.com
Wed May 25 14:09:31 UTC 2022


On 5/25/22 6:55 AM, user1234 wrote:
> On Wednesday, 25 May 2022 at 06:04:10 UTC, frame wrote:
>> On Wednesday, 25 May 2022 at 05:56:28 UTC, Steven Schveighoffer wrote:
>>
>>> It's a case where the compiler can't divine what you were thinking 
>>> when you wrote that code ;)
>>
>> I see not in all cases but in mine. If the compiler sees the function 
>> isn't callable without arguments and it is inside an if-statement or 
>> `assert()` then it could at least suggest a pointer or ask: are you 
>> dumb? ;-)
> 
> As suggested by others, the reduction is not correct, you have stripped 
> too muchbecause this compiles just fine:

Yes, he acknowledged that too much was stripped. I also verified similar 
code works.

But the real problem was something else. He is saying in this message 
"why doesn't the compiler recognize that in comparing a function to 
null, I really wanted to compare a function *pointer* to null", but I 
don't see how the compiler can make that leap.

Often times, I wish the compiler could just read what I was thinking 
when I wrote the code, so it could give me thought-contextual errors but 
alas, it can't.

-Steve


More information about the Digitalmars-d-learn mailing list