Can not use C99 function names as variable names in C89
| Bugzilla Link | 15150 |
| Version | unspecified |
| OS | All |
| Reporter | LLVM Bugzilla Contributor |
| CC | @gribozavr |
Extended Description
The following code doesn't compile in clang, but does in gcc:
int logf = 5;
int main() {
return logf;
}
# gcc test.c -o test -std=c89
# ./test; echo $?
5
# clang test.c -o test -std=c89
test.c:1:5: error: redefinition of 'logf' as different kind of symbol
int logf = 5;
^
test.c:1:5: note: previous definition is here
test.c:4:16: warning: incompatible pointer to integer conversion returning 'float (float)' from a function with result type 'int' [-Wint-conversion]
return logf;
^~~~
1 warning and 1 error generated.
@llvm/issue-subscribers-c
@llvm/issue-subscribers-clang-frontend
Hi!
This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:
- Check that no other contributor has already been assigned to this issue. If you believe that no one is actually working on it despite an assignment, ping the person. After one week without a response, the assignee may be changed.
- In the comments of this issue, request for it to be assigned to you, or just create a pull request after following the steps below. Mention this issue in the description of the pull request.
- Fix the issue locally.
- Run the test suite locally. Remember that the subdirectories under
test/create fine-grained testing targets, so you can e.g. usemake check-clang-astto only run Clang's AST tests. - Create a Git commit.
- Run
git clang-format HEAD~1to format your changes. - Open a pull request to the upstream repository on GitHub. Detailed instructions can be found in GitHub's documentation. Mention this issue in the description of the pull request.
If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below.
@llvm/issue-subscribers-good-first-issue
Author: None (llvmbot)
Extended Description
The following code doesn't compile in clang, but does in gcc:
int logf = 5; int main() { return logf; }
gcc test.c -o test -std=c89
./test; echo $?
5
clang test.c -o test -std=c89
test.c:1:5: error: redefinition of 'logf' as different kind of symbol int logf = 5; ^ test.c:1:5: note: previous definition is here test.c:4:16: warning: incompatible pointer to integer conversion returning 'float (float)' from a function with result type 'int' [-Wint-conversion] return logf; ^~~~ 1 warning and 1 error generated.
I am working on this
@tlemy are you still working on this one?
@vinay-deshmukh no
Thanks, I'll take this up then!
Hey, @vinay-deshmukh are you still working on this? If not, I would like to take this up.
Hey, @vinay-deshmukh are you still working on this? If not, I would like to take this up.
Go for it!
@RoshanYSingh23 Please note, we don't assign issues until there is a PR and we check and make sure it is headed in the right direction.