Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning with newer GCC versions in matrix_free/fe_evaluation.h #13051

Closed
bangerth opened this issue Dec 9, 2021 · 3 comments · Fixed by #13091
Closed

Warning with newer GCC versions in matrix_free/fe_evaluation.h #13051

bangerth opened this issue Dec 9, 2021 · 3 comments · Fixed by #13091
Milestone

Comments

@bangerth
Copy link
Member

bangerth commented Dec 9, 2021

[226/939] Building CXX object examples/CMakeFiles/step-76.release.dir/step-76/step-76.cc.o
In file included from /home/bangerth/p/deal.II/1/dealii/examples/step-76/step-76.cc:46:
In member function ‘void dealii::FEEvaluationBase<dim, n_components_, Number, <anonymous>, <template-parameter-1-5> >::read_write_operation(const VectorOperation&, const std::array<VectorType*, n_components_>&, const std::array<const std::vector<dealii::ArrayView<const typename VectorType::value_type> >*, n_components_>&, const std::bitset<VectorizedArrayType::size()>&, bool) const [with VectorType = dealii::LinearAlgebra::distributed::Vector<double>; VectorOperation = dealii::internal::VectorDistributorLocalToGlobal<double, dealii::VectorizedArray<double, 2> >; int dim = 2; int n_components_ = 4; Number = double; bool is_face = false; VectorizedArrayType = dealii::VectorizedArray<double, 2>]’,
    inlined from ‘void dealii::FEEvaluationBase<dim, n_components_, Number, <anonymous>, <template-parameter-1-5> >::distribute_local_to_global(VectorType&, unsigned int, const std::bitset<VectorizedArrayType::size()>&) const [with VectorType = dealii::LinearAlgebra::distributed::Vector<double>; int dim = 2; int n_components_ = 4; Number = double; bool is_face = false; VectorizedArrayType = dealii::VectorizedArray<double, 2>]’ at /home/bangerth/p/deal.II/1/dealii/include/deal.II/matrix_free/fe_evaluation.h:4598:23,
    inlined from ‘Euler_DG::EulerOperator<2, 5, 7>::perform_stage(unsigned int, Euler_DG::Number, Euler_DG::Number, Euler_DG::Number, const dealii::LinearAlgebra::distributed::Vector<double>&, dealii::LinearAlgebra::distributed::Vector<double>&, dealii::LinearAlgebra::distributed::Vector<double>&) const::<lambda(const auto:56&, auto:57&, const auto:58&, auto:59)> [with auto:56 = dealii::MatrixFree<2, double, dealii::VectorizedArray<double, 2> >; auto:57 = dealii::LinearAlgebra::distributed::Vector<double>; auto:58 = dealii::LinearAlgebra::distributed::Vector<double>; auto:59 = std::pair<unsigned int, unsigned int>]’ at /home/bangerth/p/deal.II/1/dealii/examples/step-76/step-76.cc:939:47:
/home/bangerth/p/deal.II/1/dealii/include/deal.II/matrix_free/fe_evaluation.h:3744:24: warning: ‘void* __builtin_memset(void*, int, long unsigned int)’ offset [24, 2040] is out of the bounds [0, 16] of object ‘dof_indices’ with type ‘const unsigned int* [2]’ [-Warray-bounds]
 3744 |         dof_indices[v] = nullptr;
      |         ~~~~~~~~~~~~~~~^~~~~~~~~
/home/bangerth/p/deal.II/1/dealii/include/deal.II/matrix_free/fe_evaluation.h: In lambda function:
/home/bangerth/p/deal.II/1/dealii/include/deal.II/matrix_free/fe_evaluation.h:3669:23: note: ‘dof_indices’ declared here
 3669 |   const unsigned int *dof_indices[n_lanes];
      |                       ^~~~~~~~~~~
@bangerth bangerth added this to the Release 10.0 milestone Dec 9, 2021
@bangerth
Copy link
Member Author

bangerth commented Dec 9, 2021

Also:

/home/bangerth/p/deal.II/1/dealii/include/deal.II/matrix_free/fe_evaluation.h:3710:24: warning: ‘void* __builtin_memset(void*, int, long unsigned int)’ offset [24, 2040] is out of the bounds [0, 16] of object ‘dof_indices’ with type ‘const unsigned int* [2]’ [-Warray-bounds]
 3710 |         dof_indices[v] = nullptr;
      |         ~~~~~~~~~~~~~~~^~~~~~~~~

@kronbichler
Copy link
Member

kronbichler commented Dec 15, 2021

This compiler seems to be pedantic, doesn't it? It tries to call memset with bounds 24, 2040, but the array length is only of 2 size_t (n_lanes=2) and the index range in the line above is also within n_vectorization_actual and n_lanes. The only way this would happen is that the compiler believes the integer could need to wrap around max_unsigned_int. It might help if we fix this

unsigned int n_vectorization_actual =
this->dof_info
->n_vectorization_lanes_filled[this->dof_access_index][this->cell];

to std::min(... what we do now ..., n_lanes);?

@kronbichler
Copy link
Member

Alternatively, we can declare both variables as std::size_t, then the compiler should again know that we cannot wrap around the max index as this is a memory index.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants