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

Compile error assigning __func__ to _Nt_array_ptr<const char> in unchecked scope #727

Open
kyleheadley opened this issue Oct 15, 2021 · 2 comments
Labels
-addcr benchmark failure A bug causing a failure in our nightly benchmark tests

Comments

@kyleheadley
Copy link
Member

kyleheadley commented Oct 15, 2021

The predefined identifier __func__ represents the name of the enclosing function as a const char []. This is used in macros in 3C's icecast benchmark. It can be assigned to an _Nt_array_ptr<const char>, but only in a checked scope. 3C doesn't insert that checked scope without -addcr and block safety, but still rewrites to the nt array pointer.

We need a better way to handle these situations.

@kyleheadley kyleheadley added -addcr benchmark failure A bug causing a failure in our nightly benchmark tests labels Oct 15, 2021
@john-h-kastner
Copy link
Collaborator

A concrete failing test case:

#include<string.h>
void test(void) {
  char *d = __func__;
  strlen(d);
}

converts to

#include<string.h>
void test(void) {
  _Nt_array_ptr<char> d = __func__;
  strlen(d);
}

but this fails to compile with

error: initializing '_Nt_array_ptr<char>' with an expression of incompatible type 'const char [5]'
  _Nt_array_ptr<char> d = __func__;

@mattmccutchen-cci
Copy link
Member

It looks like a cast would come to our rescue again, just as in #725:

void test(void) {
  // Error
  _Nt_array_ptr<char> p = __func__;
  // No error
  _Nt_array_ptr<char> p2 = (_Nt_array_ptr<char>) __func__;
}

We can go ahead and do that in 3C. Ideally, we'd also file a bug against the compiler.

@mattmccutchen-cci mattmccutchen-cci changed the title Handle use of __func__ Compile error assigning __func__ to _Nt_array_ptr<const char> in unchecked scope Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-addcr benchmark failure A bug causing a failure in our nightly benchmark tests
Projects
None yet
Development

No branches or pull requests

3 participants