Issue 76686
Summary Definition of function with __attribute__((target_version("..."))) with a non-"default" value completely discarded
Labels new issue
Assignees
Reporter nabijaczleweli
    Given:
```
#include <stdlib.h>

namespace {
	__attribute__((target_version("default"))) int crc32c() {
		return 1;
	}

	__attribute__((target_version("crc"))) int crc32c() {
		// nothing
	}
}

int main() {
	return crc32c();
}
```
`c++ --target=aarch64-linux-gnu -O3 -g -Wall -Wextra -fno-exceptions -fno-rtti -std=c++20 -D_FILE_OFFSET_BITS=64 repro.cpp -o repro` there is no warning issued.

Given
```cpp
#include <stdio.h>

namespace {
	__attribute__((target_version("default"))) int crc32c() {
		return 1;
	}

	__attribute__((target_version("crc"))) int crc32c() {
		printf("crc");
	}
}

int main() {
	return crc32c();
}
```
`c++ --target=aarch64-linux-gnu -O3 -g -Wall -Wextra -fno-exceptions -fno-rtti -std=c++20 -D_FILE_OFFSET_BITS=64 repro.cpp -o repro`
```
$ nm -D repro
                 U abort@GLIBC_2.17
                 w __cxa_finalize@GLIBC_2.17
 w __gmon_start__
                 w _ITM_deregisterTMCloneTable
 w _ITM_registerTMCloneTable
                 U __libc_start_main@GLIBC_2.34
```

The body of the function, and the definition itself, is removed completely in both cases.

`Debian clang version 18.0.0 (++20231231112334+c7c912cff945-1~exp1~20231231112352.433)`
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to