[all-commits] [llvm/llvm-project] 9ea5d1: [Sema] Demote call-site-based 'alignment is a powe...

Roman Lebedev via All-commits all-commits at lists.llvm.org
Thu Feb 20 05:40:16 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 9ea5d17cc9544838c73e593de4ef224d54fa1cff
      https://github.com/llvm/llvm-project/commit/9ea5d17cc9544838c73e593de4ef224d54fa1cff
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-02-20 (Thu, 20 Feb 2020)

  Changed paths:
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/CodeGen/CGCall.cpp
    M clang/lib/Sema/SemaChecking.cpp
    A clang/test/CodeGen/non-power-of-2-alignment-assumptions.c
    M clang/test/Sema/alloc-align-attr.c
    M clang/test/SemaCXX/alloc-align-attr.cpp

  Log Message:
  -----------
  [Sema] Demote call-site-based 'alignment is a power of two' check for AllocAlignAttr into a warning

Summary:
As @rsmith notes in https://reviews.llvm.org/D73020#inline-672219
while that is certainly UB land, it may not be actually reachable at runtime, e.g.:
```
template<int N> void *make() {
  if ((N & (N-1)) == 0)
    return operator new(N, std::align_val_t(N));
  else
    return operator new(N);
}
void *p = make<7>();
```
and we shouldn't really error-out there.

That being said, i'm not really following the logic here.
Which ones of these cases should remain being an error?

Reviewers: rsmith, erichkeane

Reviewed By: erichkeane

Subscribers: cfe-commits, rsmith

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73996




More information about the All-commits mailing list