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

Use nullptr in code blocks #208

Closed
sdutoit opened this issue Oct 3, 2013 · 12 comments
Closed

Use nullptr in code blocks #208

sdutoit opened this issue Oct 3, 2013 · 12 comments
Assignees
Labels
big An issue causing a large set of changes, scattered across most of the text.

Comments

@sdutoit
Copy link
Contributor

sdutoit commented Oct 3, 2013

Use nullptr where we currently use 0 or NULL.

@sdutoit
Copy link
Contributor Author

sdutoit commented Oct 3, 2013

Related to #52, which is about null values in normative text.

@sdutoit
Copy link
Contributor Author

sdutoit commented Oct 3, 2013

From a PDF sent to LWG by Geoff Alexander:

C++11 changes to use nullptr rather than 0
Location
From Text
To Text
section 8.3.2, paragraph 3, page 188
p = 0;
p = nullptr;
section 8.3.2, paragraph 3, page 188
q with the value zero
q with the value nullptr
section 9.7, paragraph 1, page 230
inner* p = 0;
inner* p = nullptr;
section 9.8, paragraph 1, page 231
local* p = 0;
local* p = nullptr;
section 14.5.6.2, paragraph 5, page 350
A<U, T>* p = 0
A<U, T>* p = nullptr
section 14.5.6.2, paragraph 5, page 350
A<U, U>* p = 0
A<U, U>* p = nullptr
section 14.7.3, paragraph 13, page 373
char* p = 0;
char* p = nullptr;
section 17.6.5.4, paragraph 4, page 450
delim != 0
delim != nullptr
section 29.6.9, page 535
hint = 0
hint = nullptr
section 29.6.9.1, paragraph 4, page 536
hint = 0
hint = nullptr
section 21.3, page 637 (multiple occurrences)
size_t idx = 0
size_t *idx = nullptr
section 21.5, pages 665-666 (multiple occurrences)
size_t *idx = 0
size_t *idx = nullptr
section 21.5, pages 665-666 (multiple occurrences)
idx != 0
idx != nullptr
section 21.3.3.2.3, paragraph 2, page 683
std::streambuf *bytebuf = 0
std::streambuf *bytebuf = nullptr
section 21.3.3.2.3, paragraph 9, page 684
std::streambuf *bytebuf = 0
std::streambuf *bytebuf = nullptr
section 22.4.1.3, page 688
const mask
tab = 0
const mask* tab = nullptr
section 22.4.1.3.2, paragraph 2, page 689
const mask* tbl = 0
const mask* tbl = nullptr
section 22.4.1.3.2, paragraph 2, page 690
tbl either 0
tbl either nullptr
section 24.6.1.1, paragraph 2, page 856
in_stream == 0
in_stream == nullptr
section 24.6.1.2, paragraph 3, page 857
in_stream != 0
in_stream != nullptr
section 24.6.1.2, paragraph 6, page 857
in_stream != 0
in_stream != nullptr
section 24.6.2.2, paragraph 1, page 858
delim != 0
delim != nullptr
section 27.5.5.3, paragraph 9, page 1007
rdbuf() != 0
rdbuf() != nullptr
section 27.5.5.4, paragraph 4, page 1009
rdbuf() != 0
rdbuf() != nullptr
section 27.5.5.4, paragraph 5, page 1009
rdbuf()
rdbuf() != nullptr
section D.7.1, page 1231-1232 (multiple occurrences)
char* pbeg_arg = 0
char* pbeg_arg = nullptr
section D.7.1.1, page 1233 (multiple occurrences)
char* pbeg_arg = 0
char* pbeg_arg = nullptr
section D.10.1, page 1245 (multiple occurrences)
X* p =0
X* p = nullptr
section D.10.1.1, page 1246
X* p =0
X* p = nullptr
section D.10.1.2, page 1247
get() != 0
get() != nullptr
section D.10.1.2, page 1247
X* p =0
X* p = nullptr


@jwakely jwakely self-assigned this Aug 5, 2014
@Eelis
Copy link
Contributor

Eelis commented Jul 30, 2016

Here's the result of egrep "\* *[a-zA-Z_]* *= *0" *.tex (perhaps easier to read than the list above):

classes.tex:597:  T * p = 0;        // OK: \grammarterm{brace-or-equal-initializer}
classes.tex:1434:inner* p = 0;                   // error: \tcode{inner} not in scope
classes.tex:1798:local* p = 0;                   // error: \tcode{local} not in scope
future.tex:154:    strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = 0);
future.tex:158:                 signed char* pbeg_arg = 0);
future.tex:161:                 unsigned char* pbeg_arg = 0);
future.tex:311:strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = 0);
future.tex:313:             signed char* pbeg_arg = 0);
future.tex:315:             unsigned char* pbeg_arg = 0);
locales.tex:1323:    explicit wbuffer_convert(std::streambuf* bytebuf = 0,
locales.tex:1409:explicit wbuffer_convert(std::streambuf* bytebuf = 0,
locales.tex:1954:    explicit ctype(const mask* tab = 0, bool del = false,
locales.tex:2048:explicit ctype(const mask* tbl = 0, bool del = false,
strings.tex:754:  int stoi(const string& str, size_t* idx = 0, int base = 10);
strings.tex:755:  long stol(const string& str, size_t* idx = 0, int base = 10);
strings.tex:756:  unsigned long stoul(const string& str, size_t* idx = 0, int base = 10);
strings.tex:757:  long long stoll(const string& str, size_t* idx = 0, int base = 10);
strings.tex:758:  unsigned long long stoull(const string& str, size_t* idx = 0, int base = 10);
strings.tex:759:  float stof(const string& str, size_t* idx = 0);
strings.tex:760:  double stod(const string& str, size_t* idx = 0);
strings.tex:761:  long double stold(const string& str, size_t* idx = 0);
strings.tex:772:  int stoi(const wstring& str, size_t* idx = 0, int base = 10);
strings.tex:773:  long stol(const wstring& str, size_t* idx = 0, int base = 10);
strings.tex:774:  unsigned long stoul(const wstring& str, size_t* idx = 0, int base = 10);
strings.tex:775:  long long stoll(const wstring& str, size_t* idx = 0, int base = 10);
strings.tex:776:  unsigned long long stoull(const wstring& str, size_t* idx = 0, int base = 10);
strings.tex:777:  float stof(const wstring& str, size_t* idx = 0);
strings.tex:778:  double stod(const wstring& str, size_t* idx = 0);
strings.tex:779:  long double stold(const wstring& str, size_t* idx = 0);
strings.tex:4362:int stoi(const string& str, size_t* idx = 0, int base = 10);
strings.tex:4363:long stol(const string& str, size_t* idx = 0, int base = 10);
strings.tex:4364:unsigned long stoul(const string& str, size_t* idx = 0, int base = 10);
strings.tex:4365:long long stoll(const string& str, size_t* idx = 0, int base = 10);
strings.tex:4366:unsigned long long stoull(const string& str, size_t* idx = 0, int base = 10);
strings.tex:4396:float stof(const string& str, size_t* idx = 0);
strings.tex:4397:double stod(const string& str, size_t* idx = 0);
strings.tex:4398:long double stold(const string& str, size_t* idx = 0);
strings.tex:4459:int stoi(const wstring& str, size_t* idx = 0, int base = 10);
strings.tex:4460:long stol(const wstring& str, size_t* idx = 0, int base = 10);
strings.tex:4461:unsigned long stoul(const wstring& str, size_t* idx = 0, int base = 10);
strings.tex:4462:long long stoll(const wstring& str, size_t* idx = 0, int base = 10);
strings.tex:4463:unsigned long long stoull(const wstring& str, size_t* idx = 0, int base = 10);
strings.tex:4491:float stof(const wstring& str, size_t* idx = 0);
strings.tex:4492:double stod(const wstring& str, size_t* idx = 0);
strings.tex:4493:long double stold(const wstring& str, size_t* idx = 0);
templates.tex:2882:template<class T, class U> void f(U, A<U, T>* p = 0); // \#1
templates.tex:2883:template<         class U> void f(U, A<U, U>* p = 0); // \#2
templates.tex:5069:char* p = 0;

I'd be happy to provide a patch for this.

@Eelis
Copy link
Contributor

Eelis commented Jul 30, 2016

Ah, and most of these should be replaced as well (egrep "\* *\) *0" *.tex):

compatibility.tex:257:p = (void*)(struct x {int i;} *)0;
declarators.tex:1654:template <class T, class U> decltype((*(T*)0) + (*(U*)0)) add(T t, U u);
expressions.tex:2266:  static_cast<D*>((B*)0);               // Error: B is a private base of D.
expressions.tex:2267:  static_cast<int B::*>((int D::*)0);   // Error: B is a private base of D.
expressions.tex:2415:\tcode{(void*)0} to the integral type. \begin{note} A \tcode{reinterpret_cast}
support.tex:88:\tcode{(void*)0}.}
templates.tex:2888:  f<int>(42, (A<int, int>*)0);                        // calls \#2

@Eelis
Copy link
Contributor

Eelis commented Jul 30, 2016

Hmm 0 as a nullptr appears in various other contexts as well, and not all uses of 0 as a nullptr should be replaced, so now I'm just going over all occurrences of 0 in the standard, preparing a patch.

@jensmaurer
Copy link
Member

Is there any progress on the patch?

@jensmaurer jensmaurer added the big An issue causing a large set of changes, scattered across most of the text. label Nov 13, 2016
@faisalv
Copy link
Contributor

faisalv commented Nov 14, 2016

Just out of curiosity, what's the rationale for putting any effort at all into replacing these 0's w nullptr?

@Eelis
Copy link
Contributor

Eelis commented Nov 17, 2016

(I had a patch but retracted it, no progress from me on this item.)

@jensmaurer
Copy link
Member

@faisalv: I presume we want to show "good" coding practice in the library parts of the standard. In contrast, we want to show a variety of coding styles in the core parts of the standard, avoiding core endorsement of a particular one.

@jensmaurer
Copy link
Member

Do we want to replace 0 with nullptr in the library sections of the standard?

@jensmaurer jensmaurer added the decision-required A decision of the editorial group (or the Project Editor) is required. label Dec 14, 2016
@jensmaurer
Copy link
Member

Editorial meeting consensus: Agreed with "Do we want to replace 0 with nullptr in the library sections of the standard?"

@jensmaurer jensmaurer removed the decision-required A decision of the editorial group (or the Project Editor) is required. label Mar 2, 2017
@jensmaurer
Copy link
Member

Updated wiki page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
big An issue causing a large set of changes, scattered across most of the text.
Projects
None yet
Development

No branches or pull requests

5 participants