home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c      Meh, in C you gotta define EVERYTHING      243,242 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 242,197 of 243,242   
   bart to Keith Thompson   
   Re: _BitInt(N)   
   28 Nov 25 00:11:53   
   
   From: bc@freeuk.com   
      
   On 27/11/2025 23:59, Keith Thompson wrote:   
   > bart  writes:   
   >> On 27/11/2025 10:43, David Brown wrote:   
   > [...]   
   >>> uint64_t get_exponent(double x) {   
   >>>       return ((union { double d; uint64_t u;}) { x }.u >> 52)   
   >>>                & ((1ull << (62 - 52 + 1)) - 1);   
   >>> }   
   >>> That compiles (with gcc on x86-64) to :   
   >>>       movq rax, xmm0   
   >>>       shr rax, 52   
   >>>       and eax, 2047   
   >>>       ret   
   >>> There's nothing in C that suggests this must be put in memory or do   
   >>> anything more than this.   
   >>   
   >> (This only seems to work with gcc. Clang and MSVS don't like it.)   
   >   
   > How exactly did clang and msvs express their dislike?  What versions are   
   > you using?   
   >   
   > On my systems, it works correctly with gcc 13.3.0, clang 18.1.3,   
   > tcc 0.9.27, Microsoft Visual Studio 2022 17.14.20.   
   >   
   > If your problem is that you're using older compilers that don't support   
   > compound literals, it would have saved some time if you had said so.   
   >   
      
   I said in a followup that I'd been using a C++ compiler by mistake (this   
   was on Godbolt).   
      
   That gcc's C++ compiler accepted the code wasn't helpful.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca