Suspicious shift

Aperta
#306 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
cpp
Ambito
backend

Direzione di ricerca

Start with basisu.h around line 310 and inspect the NumBytes == 8 conversion alongside the other switch cases. Check the return type and the iOS arm64 clang warning to determine whether the shift is intentional or loses required data. Done means the conversion behavior is correct and the reported warning is resolved.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

invalid

In basisu.h at line 310 is

		inline operator uint32_t() const
		{
			switch (NumBytes)
			{
                                 ...
				case 8:  
				{
					uint32_t l = read_le_dword(m_bytes);
					uint32_t h = read_le_dword(m_bytes + 4);
					return static_cast<uint64_t>(l) | (static_cast<uint64_t>(h) << 32U);  <=========
				}
                                ...
			}
		}

When compiling for iOS arm64, the latest Xcode/clang (13.5 / 13.1.6) throws an implicit conversion loses integer precision warning which drew my attention to the highlighted line. This line looks extremely suspicious because the shift of h by 32-bits is throwing away the value of h in so far as the 32-bit return value will never see it. Many other cases also return a value that is statically cast to 64-bits which seems pointless as the return value is uint32_t. There is no warning on those cases.

If the highlighted line is truly correct, please add additional casts to fix the warnings, otherwise fix the code.

Lingua principale
C++
Stelle
3.1k
Fork
347
Merge medio
4g 3h
PR unite (30g)
1

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di BinomialLLC/basis_universal

Tutte le issue di BinomialLLC/basis_universal

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.