TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 228 subscribers
Post #24081 25
Is there an attribute to tell the compiler that the value of a const object reference/pointer parameter is truly not modified


I tried restrict but it seems that it still notbthe case ,
I'm not talking about the unsequensed ,gcc pure , const and similar c attributes that apply to the whole function , I mean something like ( im not a wg21 guy , but looking at c wording for restrict i can peace something) :

For a stable pointer to a const type T , P existing in block B , if any value V with address A is accessed through a pointer originating from P , for as long as the block B is active , the statement
memcmp(std::addressof(V),A,sizeof(V))==0 must be true, otherwise the behavior is undefined


https://redd.it/1oa8w6c
@r_cpp
Reddit From the cpp community on Reddit Explore this post and more from the cpp community
More from @r_cpp
  1. Oct 14, 2026I tested whether a coding agent would use C++23 ranges without being told Blog post: https…
  2. Oct 14, 2026C++ futures part 1: The mental model https://devblogs.microsoft.com/oldnewthing/20261012-0…
  3. Oct 14, 2026C++ futures part 2: The mental model for std::promise, std::packaged_task https://devblogs…
  4. Oct 12, 2026[Release] slick-logger v2.2.0 — Lock-free asynchronous C++20 logging with multi-process sh…
  5. Oct 12, 2026Cheap alternative to reboot parameters (nohz, rcu, isolcpus) for stable benchmarks When no…
  6. Oct 12, 2026This C++ drama is crazy - Adobe votes no https://www.youtube.com/watch?v=DEqx_NMMH9Q https…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →