llvm / llvm/llvm-project

New __ptrauth scalar types are wrongly reported as trivially copy/move constructible

Open
#170,244 7 comments 1 reaction 0 assignees View on GitHub
clang:frontend
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Follows #137473 and #154394.
https://godbolt.org/z/zhsdnxKPe
```
using PA = void * __ptrauth(0,1,0);
template struct H { T t; };

static_assert(!__is_trivially_copyable(PA));
static_assert(__is_trivially_constructible(PA, PA&)); // WRONG
static_assert(__is_trivially_assignable(PA&, PA&)); // WRONG
static_assert(!__is_trivially_copyable(H));
static_assert(!__is_trivially_constructible(H, H&));
static_assert(!__is_trivially_assignable(H&, H&));
```
It cannot be that `PA` is trivially constructible and assignable by itself alone, but becomes non-trivial only when placed into a class type `H`. It also cannot be that `PA` is trivially constructible, assignable, and destructible, yet is not trivially_copyable. The conclusion is that `PA` must be non-trivial even when it is alone.

@ojhunt will you look please?

Contributor guide

Open the contributing guide

Research direction

Start with the Compiler Explorer reproducer linked in the issue and inspect how the new __ptrauth scalar type is classified by the trivial construction and assignment traits. The fix is complete when the listed static assertions pass consistently for PA and H.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.