[Interest] Future of constexpr in Qt?

Thiago Macieira thiago.macieira at intel.com
Mon Nov 25 18:16:12 CET 2024


On Monday 25 November 2024 00:39:37 Pacific Standard Time Schimkowitsch Robert 
wrote:
> Well, my idea was mostly to test extreme cases in constexpr context, so you
> get compiler errors if you overlooked something and e.g. cause unsigned
> wraparound when getting passed int_max. 

That should be done in unit testing, wherever possible. Some conditions we 
simply can't test, such as *succeeding* in allocating a memory block of a size 
comparable to PTRDIFF_MAX because such a block is not architecturally possible 
(on 64-bit machines). As a rule of thumb for test writers: always test your 
boundary conditions.

> But as mentioned above, the number
> of useful functions I can write constexpr is probably limited. I believe
> Herb rather meant this example to show that it is possible to reduce the
> amount of UB allowed in the language.


-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Principal Engineer - Intel DCAI Platform & System Engineering
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5152 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20241125/9cc84c6f/attachment.bin>


More information about the Interest mailing list