Code review of a code example in the C++Standard.:)

52 views
Skip to first unread message

Vladimir Grigoriev

unread,
Jul 26, 2025, 4:13:52 PMJul 26
to std-discussion
In the section «11.4.3 Non-static member functions» of the C++23 Standard there is present the following code example (example 1):
 
void tnode::set(const char* w, tnode* l, tnode* r) {
    count = strlen(w)+1;
    if (sizeof(tword)<=count)
        perror("tnode string too long");
    strcpy(tword,w);
    left = l;
    right = r;
}
 
Should it be
 
    if (sizeof(tword)<count)
 
instead of
 
    if (sizeof(tword)<=count)
 
?
 
With best regards
(Vlad from Moscow)
Reply all
Reply to author
Forward
0 new messages