cast.hpp: integer bounds raise ~3,600 Clang warnings and reject the long long minimum when long double is 64-bit
I maintainer di solito rispondono entro 2 giorni
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 82/100
Direzione di ricerca
Inizia da src/alps/utilities/include/alps/utilities/cast.hpp, in checked_integer_string, dove i limiti con segno e senza segno sono costruiti da numeric_limits più 1.L e meno 1.L. Sostituiscili con potenze di due tramite std::ldexp e rendi inclusivo il controllo del limite inferiore con segno, come descritto nell'issue. Poi estendi il test di cast esistente con il minimo di long long scritto in decimale, e verifica che venga accettato e che non compaia più l'avviso di Clang.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
With Clang, checked_integer_string in src/alps/utilities/include/alps/utilities/cast.hpp raises -Wimplicit-const-int-float-conversion once for every file that includes it. A full macOS build with applications and tests (AppleClang 21) prints about 3,600 of these warnings, which hides real ones.
The bounds are written as (std::numeric_limits<long long>::max)() + 1.L and (std::numeric_limits<long long>::min)() - 1.L, and the same for unsigned long long. Neither value can be stored exactly in a long double that is a plain double, as on Apple arm64 and MSVC, so it is rounded:
- The upper bounds round to exactly 2^63 and 2^64. Those are the values the code wants, so the checks still work.
- The lower bound rounds to −2^63, and the test is
real > bound. So the input-9223372036854775808.0is rejected as out of range, even though it is the minimum oflong long. With an 80-bitlong double(x86 Linux) it is accepted.
Fix
Write the bounds as exact powers of two, and make the lower test inclusive:
// signed branch
long double const limit = std::ldexp(1.0L, std::numeric_limits<long long>::digits); // 2^63
if (!(real >= -limit && real < limit))
// unsigned branch
long double const limit = std::ldexp(1.0L, std::numeric_limits<unsigned long long>::digits); // 2^64
if (!(real < limit))
Results do not change for any input, except that the long long minimum written as a decimal is accepted on every platform. Add a case for it to the existing cast test.
- Lingua principale
- C++
- Stelle
- 32
- Fork
- 10
- Merge medio
- 3g 19h
- PR unite (30g)
- 100
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ALPSim/ALPS
-
area:dmrg bug P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
-
P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 2 giorni
-
area:ed bug P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
I maintainer di solito rispondono entro 2 giorni
-
[Bug]: loadMeasurements without names returns nothing for worm results (Time interval has no mean)Apertaarea:python bug P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 2 giorni
-
P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
I maintainer di solito rispondono entro 2 giorni
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
Niko1221/Strata#7211 · 3 commenti ·
I maintainer di solito rispondono entro 5 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
Termux compilation failureApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement P5 XS
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
open-astro/AlpacaBridge#2683 ·
I maintainer di solito rispondono entro 1 giorno
-
Linux Copr构建失败Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 69/100
metasequoiaime/msime#11908 ·
I maintainer di solito rispondono entro 1 giorno