mercredi 7 octobre 2020

New arr[on-the-fly-size] in c++ 11 [duplicate]

Look at this code:

int nIndicrs = 2*nSides;
auto* arr = new int[nIndices];
if(!arr) return false;

My clang-tidy tool complains that the if will always be true. Why?

Shouldn't I get a nullptr in case the allocation fails? What's the proper way to test a successful new call?

If it makes any difference, this code is using c++ 11 being compiled using Android ndk v21.3.

Aucun commentaire:

Enregistrer un commentaire