Nothing Special   »   [go: up one dir, main page]

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

Fix nullptr not declared error in CPP backend #310

Closed
wants to merge 1 commit into from

Conversation

felixonmars
Copy link
Contributor
@felixonmars felixonmars commented Oct 29, 2020

nullptr becomes a keyword since C++11. Let's use NULL instead.

g++ -g --ansi -W -Wall -Wno-unused-parameter -Wno-unused-function -Wno-unneeded-internal-declaration -c Test.C
Test.C:50:21: warning: identifier ‘nullptr’ is a keyword in C++11 [-Wc++11-compat]
   50 |   Exp *parse_tree = nullptr;
      |                     ^~~~~~~
Test.C: In function ‘int main(int, char**)’:
Test.C:50:21: error: ‘nullptr’ was not declared in this scope
At global scope:
cc1plus: note: unrecognized command-line option ‘-Wno-unneeded-internal-declaration’ may have been intended to silence earlier diagnostics
make: *** [Makefile:48: Test.o] Error 1

@andreasabel
Copy link
Member

Thanks for reporting this bug.
This use of nullptr was introduced in recent commit ecccc61 in PR #288.
Funnily, my C++ compiler does not complain here, must be Apple's fault.

$ g++ --version
Apple clang version 11.0.0 (clang-1100.0.33.17)

This is why I didn't notice this problem.

I wonder whether the better solution isn't to simply use NULL instead of nullptr and stay compatible with C++98. Note that just a few lines above the problematic *parse_tree = nullptr there is the statement char *filename = NULL. Thus, it is more consistent to continue to use NULL.

@andreasabel andreasabel added bug C++ test Concerning the generated test program labels Oct 29, 2020
@andreasabel andreasabel added this to the 2.9 milestone Oct 29, 2020
`nullptr` becomes a keyword since C++11. Let's use `NULL` instead.

```
g++ -g --ansi -W -Wall -Wno-unused-parameter -Wno-unused-function -Wno-unneeded-internal-declaration -c Test.C
Test.C:50:21: warning: identifier ‘nullptr’ is a keyword in C++11 [-Wc++11-compat]
   50 |   Exp *parse_tree = nullptr;
      |                     ^~~~~~~
Test.C: In function ‘int main(int, char**)’:
Test.C:50:21: error: ‘nullptr’ was not declared in this scope
At global scope:
cc1plus: note: unrecognized command-line option ‘-Wno-unneeded-internal-declaration’ may have been intended to silence earlier diagnostics
make: *** [Makefile:48: Test.o] Error 1
```
@felixonmars
Copy link
Contributor Author

Updated.

FTR, I am using the GNU toolchain:

$ g++ --version
g++ (GCC) 10.2.0

@andreasabel
Copy link
Member

Thanks for the update! I also installed the GNU compiler now and confirmed the problem and the fix.

Thanks for your contribution. I fixed two more regressions of #288 along the way, see 3b751a6 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug C++ test Concerning the generated test program
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants