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

Incorrect error reported for deleted function #134265

Closed
ilovepi opened this issue Apr 3, 2025 · 6 comments · Fixed by #134357
Closed

Incorrect error reported for deleted function #134265

ilovepi opened this issue Apr 3, 2025 · 6 comments · Fixed by #134357
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer

Comments

@ilovepi
Copy link
Contributor

ilovepi commented Apr 3, 2025

Some time since 0454dd8 clang has started emitting an error for using a deleted function, except that function is not used.

struct Foo {
  virtual ~Foo() {}
  static void operator delete[](void* ptr) = delete;
};
<source>:2:11: error: attempt to use a deleted function
    2 |   virtual ~Foo() {}
      |           ^
<source>:3:15: note: 'operator delete[]' has been explicitly marked deleted here
    3 |   static void operator delete[](void* ptr) = delete;
      |               ^
1 error generated.
Compiler returned: 1

Godbolt: https://godbolt.org/z/aW31816h4

Surprisingly, this doesn't appear to manifest on godbolt w/ the assertions enabled, but in my local build (RelWithDebInfo + assertions) they do.

I'm bisecting now, but #133451 and #128866 seem like they could be related.

cc: @momo5502 @Fznamznon

@ilovepi ilovepi added bug Indicates an unexpected problem or unintended behavior clang Clang issues not falling into any other category labels Apr 3, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 3, 2025

@llvm/issue-subscribers-bug

Author: Paul Kirth (ilovepi)

Some time since 0454dd8 clang has started emitting an error for using a deleted function, except that function is not used.
struct Foo {
  virtual ~Foo() {}
  static void operator delete[](void* ptr) = delete;
};
&lt;source&gt;:2:11: error: attempt to use a deleted function
    2 |   virtual ~Foo() {}
      |           ^
&lt;source&gt;:3:15: note: 'operator delete[]' has been explicitly marked deleted here
    3 |   static void operator delete[](void* ptr) = delete;
      |               ^
1 error generated.
Compiler returned: 1

Godbolt: https://godbolt.org/z/aW31816h4

Surprisingly, this doesn't appear to manifest on godbolt w/ the assertions enabled, but in my local build (RelWithDebInfo + assertions) they do.

I'm bisecting now, but #133451 and #128866 seem like they could be related.

cc: @momo5502 @Fznamznon

@EugeneZelenko EugeneZelenko added clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer and removed bug Indicates an unexpected problem or unintended behavior clang Clang issues not falling into any other category labels Apr 3, 2025
@momo5502
Copy link
Contributor

momo5502 commented Apr 3, 2025

Hm. My first guess would be that it's not related to #128866, because that change only affected members within a constructor. However, I might as well be wrong.

@ilovepi
Copy link
Contributor Author

ilovepi commented Apr 3, 2025

Bisected to #133950.

@Fznamznon can you take a look? This is currently hitting our CI when building Fuchsia https://ci.chromium.org/ui/p/fuchsia/builders/ci/clang_toolchain.ci.core.x64-debug-tot-build_only/b8718579542173931569/overview

If this will take a while to triage, would you mind reverting until it can be fixed?

@Fznamznon
Copy link
Contributor

Hi, I'll take a look.

Fznamznon added a commit to Fznamznon/llvm-project that referenced this issue Apr 4, 2025
For vector deleting dtors support we now also search and save
operator delete[]. Avoid diagnosing deleted operator delete[] when doing that
because vector deleting dtors are only called when delete[] is present and
whenever delete[] is present in the TU it will be diagnosed correctly.

Fixes llvm#134265
@Fznamznon
Copy link
Contributor

I created a fix, sorry about inconvenience!

llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this issue Apr 4, 2025
…#134357)

For vector deleting dtors support we now also search and save operator
delete[]. Avoid diagnosing deleted operator delete[] when doing that
because vector deleting dtors are only called when delete[] is present
and whenever delete[] is present in the TU it will be diagnosed
correctly.

Fixes llvm/llvm-project#134265
@ilovepi
Copy link
Contributor Author

ilovepi commented Apr 4, 2025

Thanks! Can confirm this is now fixed in our CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants