Skip to content

safe_array indexing should use size_t #78

@StefanBruens

Description

@StefanBruens

size_t is the index type used for all containers in the STL.

It is a 64 bit integer on 64 bit archs, and 32 bit on 32 bit archs.

Using int64_t breaks compilation on 32 bit archs:

[   40s] safe_array.h: In instantiation of 'void safe_array<T>::resize(int64_t) [with T = std::complex<double>; int64_t = long long int]':
[   40s] matrix_algebra.cpp:281:15:   required from here
[   40s] safe_array.h:122:46: error: conversion from 'int64_t' {aka 'long long int'} to 'size_t' {aka 'unsigned int'} may change value [-Werror=conversion]
[   40s]   122 |           std::memcpy(new_data_, _data, _len * sizeof(T));
[   40s]       |                                         ~~~~~^~~~~~~~~~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions