C++ Logo

std-proposals

Advanced search

[std-proposals] Fwd: [std-discussion] Guarantees over addresses from function pointers created from lambda

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Sun, 27 Apr 2025 10:34:06 -0400
On Sun, Apr 27, 2025 at 4:50 AM Tiago Freire <tmiguelf_at_[hidden]> wrote:
>
> > Because different things should be different.
> Why?
> and
> Are they really different?

Yes.

```
void foo();
void bar();
```

Are those different? Why should adding `{}` change whether they are different?

```
constexpr int a = 0;
constexpr int b = 0;
```

By the rules of C++, if you test the addresses of these two objects,
they *must* be different. Because they have different names which
denote different entities *even if* the result of evaluating them is
known by the compiler to be the same.

> I understand different values being different, it has arithmetic consequences.
> I understand different objects being different, changing one object shouldn't change the other (need to preserve state) 🐍👀.
>
> You are more than willing to accept that constant string/array literals defined in different places could have the same address.
> The reason being if you only read from them, and the data is the same, does it really matter which copy of the data you are looking at?

Note that the two exceptions are not *named*.

The question is whether two different names, denoting two different
entities, should somehow act like they're denoting the same entity.

Received on 2025-04-27 14:34:18