[clang] Diagnose problematic uses of constructor/destructor attribute (PR #67360)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 26 12:47:51 PDT 2023


MaskRay wrote:

I haven't looked closely, but the patch made constructor with priority 0~100 an error?
```
error: 'destructor' attribute requires integer constant between 101 and 65535 inclusive
```

I think we should just use a warning to discourage user programs to use 0~100. Compiler runtime libraries and their tests can freely use 0~100. They know what they are doing and they are responsible for the interaction with other constructor users.

```
% gcc -c a.c
a.c:2:1: warning: destructor priorities from 0 to 100 are reserved for the implementation [-Wprio-ctor-dtor]
    2 | int f(void) {
      | ^~~
```

https://github.com/llvm/llvm-project/pull/67360


More information about the cfe-commits mailing list