Isn't the note below a contradiction in relation to paragraphs (2.1) and (2.2) in [basic.start.main]/2?
[basic.start.main]/2:
An implementation shall not predefine the main function. This function
shall not be overloaded. Its type shall have C++ language linkage and
it shall have a declared return type of type int, but otherwise its
type is implementation-defined. An implementation shall allow both
(2.1) a function of
()returningintand
(2.2) a function of(int,pointer to pointer tochar)returningint
as the type of
main
([dcl.fct]). In the latter form, for purposes of exposition, the first
function parameter is calledargcand the second function parameter is
calledargv, whereargcshall be the number of arguments passed to the
program from the environment in which the program is run. Ifargcis
nonzero these arguments shall be supplied inargv[0]through
argv[argc-1]as pointers to the initial characters of null-terminated
multibyte strings (NTMBSS) ([multibyte.strings]) andargv[0]shall be
the pointer to the initial character of a NTMBS that represents the
name used to invoke the program or"". The value ofargcshall be
non-negative. The value ofargv[argc]shall be0. [ Note: It is
recommended that any further (optional) parameters be added after
argv. — end note ]
c++ language-lawyer
add a comment |
[basic.start.main]/2:
An implementation shall not predefine the main function. This function
shall not be overloaded. Its type shall have C++ language linkage and
it shall have a declared return type of type int, but otherwise its
type is implementation-defined. An implementation shall allow both
(2.1) a function of
()returningintand
(2.2) a function of(int,pointer to pointer tochar)returningint
as the type of
main
([dcl.fct]). In the latter form, for purposes of exposition, the first
function parameter is calledargcand the second function parameter is
calledargv, whereargcshall be the number of arguments passed to the
program from the environment in which the program is run. Ifargcis
nonzero these arguments shall be supplied inargv[0]through
argv[argc-1]as pointers to the initial characters of null-terminated
multibyte strings (NTMBSS) ([multibyte.strings]) andargv[0]shall be
the pointer to the initial character of a NTMBS that represents the
name used to invoke the program or"". The value ofargcshall be
non-negative. The value ofargv[argc]shall be0. [ Note: It is
recommended that any further (optional) parameters be added after
argv. — end note ]
c++ language-lawyer
2
It says an implementation shall allow both, but not only both.
– Neil Butterworth
Nov 23 '18 at 18:56
2
Why do you feel this is a contradiction?
– Nicol Bolas
Nov 23 '18 at 18:57
1
Please specify what exactly you consider the contradiction. It is not clear to me how you interpret the mentioned parts of the quote.
– user10605163
Nov 23 '18 at 18:59
add a comment |
[basic.start.main]/2:
An implementation shall not predefine the main function. This function
shall not be overloaded. Its type shall have C++ language linkage and
it shall have a declared return type of type int, but otherwise its
type is implementation-defined. An implementation shall allow both
(2.1) a function of
()returningintand
(2.2) a function of(int,pointer to pointer tochar)returningint
as the type of
main
([dcl.fct]). In the latter form, for purposes of exposition, the first
function parameter is calledargcand the second function parameter is
calledargv, whereargcshall be the number of arguments passed to the
program from the environment in which the program is run. Ifargcis
nonzero these arguments shall be supplied inargv[0]through
argv[argc-1]as pointers to the initial characters of null-terminated
multibyte strings (NTMBSS) ([multibyte.strings]) andargv[0]shall be
the pointer to the initial character of a NTMBS that represents the
name used to invoke the program or"". The value ofargcshall be
non-negative. The value ofargv[argc]shall be0. [ Note: It is
recommended that any further (optional) parameters be added after
argv. — end note ]
c++ language-lawyer
[basic.start.main]/2:
An implementation shall not predefine the main function. This function
shall not be overloaded. Its type shall have C++ language linkage and
it shall have a declared return type of type int, but otherwise its
type is implementation-defined. An implementation shall allow both
(2.1) a function of
()returningintand
(2.2) a function of(int,pointer to pointer tochar)returningint
as the type of
main
([dcl.fct]). In the latter form, for purposes of exposition, the first
function parameter is calledargcand the second function parameter is
calledargv, whereargcshall be the number of arguments passed to the
program from the environment in which the program is run. Ifargcis
nonzero these arguments shall be supplied inargv[0]through
argv[argc-1]as pointers to the initial characters of null-terminated
multibyte strings (NTMBSS) ([multibyte.strings]) andargv[0]shall be
the pointer to the initial character of a NTMBS that represents the
name used to invoke the program or"". The value ofargcshall be
non-negative. The value ofargv[argc]shall be0. [ Note: It is
recommended that any further (optional) parameters be added after
argv. — end note ]
c++ language-lawyer
c++ language-lawyer
asked Nov 23 '18 at 18:52
WaldBWaldB
476311
476311
2
It says an implementation shall allow both, but not only both.
– Neil Butterworth
Nov 23 '18 at 18:56
2
Why do you feel this is a contradiction?
– Nicol Bolas
Nov 23 '18 at 18:57
1
Please specify what exactly you consider the contradiction. It is not clear to me how you interpret the mentioned parts of the quote.
– user10605163
Nov 23 '18 at 18:59
add a comment |
2
It says an implementation shall allow both, but not only both.
– Neil Butterworth
Nov 23 '18 at 18:56
2
Why do you feel this is a contradiction?
– Nicol Bolas
Nov 23 '18 at 18:57
1
Please specify what exactly you consider the contradiction. It is not clear to me how you interpret the mentioned parts of the quote.
– user10605163
Nov 23 '18 at 18:59
2
2
It says an implementation shall allow both, but not only both.
– Neil Butterworth
Nov 23 '18 at 18:56
It says an implementation shall allow both, but not only both.
– Neil Butterworth
Nov 23 '18 at 18:56
2
2
Why do you feel this is a contradiction?
– Nicol Bolas
Nov 23 '18 at 18:57
Why do you feel this is a contradiction?
– Nicol Bolas
Nov 23 '18 at 18:57
1
1
Please specify what exactly you consider the contradiction. It is not clear to me how you interpret the mentioned parts of the quote.
– user10605163
Nov 23 '18 at 18:59
Please specify what exactly you consider the contradiction. It is not clear to me how you interpret the mentioned parts of the quote.
– user10605163
Nov 23 '18 at 18:59
add a comment |
1 Answer
1
active
oldest
votes
It states that at least two signatures must be permitted; int main() and int main(int, char**).
What other types are permitted is implementation-defined.
They recommend that if your implementation permits main with more arguments, that they be added after the int, char** arguments of that particular signature. This is not forced.
The implementation could say that this is a valid main signature:
int main( std::vector<std::string> args )
or it could have:
int main( int, char**, system::permission_token )
or whatever.
This second one -- the system::permission_token -- where that is an optional argument (ie, int main(int, char**) still works), would be what the note advises. The first style is still permitted.
The quote "but otherwise its type is implementation-defined" could very well refer to the return type of the function, and not to other arguments. At least that was my interpretation.
– WaldB
Nov 23 '18 at 19:12
@WaldB Sure, you misread it. The but clause does not remove the "shall" requirement from the first part of the phrase. The type of a function includes its return value, its arguments, and (in later versions of C++) if it is noexcept. Allmainfunctions must returnint(part 1 of sentence), but everything else is implementation defined about its type (part 2 of the sentence). It then goes on to further restrict what the implemenation can define (saying it must support two different signatures, without limiting it to supporting those two).
– Yakk - Adam Nevraumont
Nov 23 '18 at 19:14
I would say that your previous comment makes sense to me. But I don't agree that anyone (including native English speakers) could arrive at this conclusion, just by reading the standard.
– WaldB
Nov 23 '18 at 19:26
@WaldB Probably the fact that "shall" has a very specific meaning in ISO standards might have tripped you up.
– Yakk - Adam Nevraumont
Nov 23 '18 at 19:37
Could you comment on this specific meaning?
– WaldB
Nov 23 '18 at 19:56
|
show 1 more comment
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53451711%2fisnt-the-note-below-a-contradiction-in-relation-to-paragraphs-2-1-and-2-2-i%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It states that at least two signatures must be permitted; int main() and int main(int, char**).
What other types are permitted is implementation-defined.
They recommend that if your implementation permits main with more arguments, that they be added after the int, char** arguments of that particular signature. This is not forced.
The implementation could say that this is a valid main signature:
int main( std::vector<std::string> args )
or it could have:
int main( int, char**, system::permission_token )
or whatever.
This second one -- the system::permission_token -- where that is an optional argument (ie, int main(int, char**) still works), would be what the note advises. The first style is still permitted.
The quote "but otherwise its type is implementation-defined" could very well refer to the return type of the function, and not to other arguments. At least that was my interpretation.
– WaldB
Nov 23 '18 at 19:12
@WaldB Sure, you misread it. The but clause does not remove the "shall" requirement from the first part of the phrase. The type of a function includes its return value, its arguments, and (in later versions of C++) if it is noexcept. Allmainfunctions must returnint(part 1 of sentence), but everything else is implementation defined about its type (part 2 of the sentence). It then goes on to further restrict what the implemenation can define (saying it must support two different signatures, without limiting it to supporting those two).
– Yakk - Adam Nevraumont
Nov 23 '18 at 19:14
I would say that your previous comment makes sense to me. But I don't agree that anyone (including native English speakers) could arrive at this conclusion, just by reading the standard.
– WaldB
Nov 23 '18 at 19:26
@WaldB Probably the fact that "shall" has a very specific meaning in ISO standards might have tripped you up.
– Yakk - Adam Nevraumont
Nov 23 '18 at 19:37
Could you comment on this specific meaning?
– WaldB
Nov 23 '18 at 19:56
|
show 1 more comment
It states that at least two signatures must be permitted; int main() and int main(int, char**).
What other types are permitted is implementation-defined.
They recommend that if your implementation permits main with more arguments, that they be added after the int, char** arguments of that particular signature. This is not forced.
The implementation could say that this is a valid main signature:
int main( std::vector<std::string> args )
or it could have:
int main( int, char**, system::permission_token )
or whatever.
This second one -- the system::permission_token -- where that is an optional argument (ie, int main(int, char**) still works), would be what the note advises. The first style is still permitted.
The quote "but otherwise its type is implementation-defined" could very well refer to the return type of the function, and not to other arguments. At least that was my interpretation.
– WaldB
Nov 23 '18 at 19:12
@WaldB Sure, you misread it. The but clause does not remove the "shall" requirement from the first part of the phrase. The type of a function includes its return value, its arguments, and (in later versions of C++) if it is noexcept. Allmainfunctions must returnint(part 1 of sentence), but everything else is implementation defined about its type (part 2 of the sentence). It then goes on to further restrict what the implemenation can define (saying it must support two different signatures, without limiting it to supporting those two).
– Yakk - Adam Nevraumont
Nov 23 '18 at 19:14
I would say that your previous comment makes sense to me. But I don't agree that anyone (including native English speakers) could arrive at this conclusion, just by reading the standard.
– WaldB
Nov 23 '18 at 19:26
@WaldB Probably the fact that "shall" has a very specific meaning in ISO standards might have tripped you up.
– Yakk - Adam Nevraumont
Nov 23 '18 at 19:37
Could you comment on this specific meaning?
– WaldB
Nov 23 '18 at 19:56
|
show 1 more comment
It states that at least two signatures must be permitted; int main() and int main(int, char**).
What other types are permitted is implementation-defined.
They recommend that if your implementation permits main with more arguments, that they be added after the int, char** arguments of that particular signature. This is not forced.
The implementation could say that this is a valid main signature:
int main( std::vector<std::string> args )
or it could have:
int main( int, char**, system::permission_token )
or whatever.
This second one -- the system::permission_token -- where that is an optional argument (ie, int main(int, char**) still works), would be what the note advises. The first style is still permitted.
It states that at least two signatures must be permitted; int main() and int main(int, char**).
What other types are permitted is implementation-defined.
They recommend that if your implementation permits main with more arguments, that they be added after the int, char** arguments of that particular signature. This is not forced.
The implementation could say that this is a valid main signature:
int main( std::vector<std::string> args )
or it could have:
int main( int, char**, system::permission_token )
or whatever.
This second one -- the system::permission_token -- where that is an optional argument (ie, int main(int, char**) still works), would be what the note advises. The first style is still permitted.
answered Nov 23 '18 at 18:56
Yakk - Adam NevraumontYakk - Adam Nevraumont
183k19189374
183k19189374
The quote "but otherwise its type is implementation-defined" could very well refer to the return type of the function, and not to other arguments. At least that was my interpretation.
– WaldB
Nov 23 '18 at 19:12
@WaldB Sure, you misread it. The but clause does not remove the "shall" requirement from the first part of the phrase. The type of a function includes its return value, its arguments, and (in later versions of C++) if it is noexcept. Allmainfunctions must returnint(part 1 of sentence), but everything else is implementation defined about its type (part 2 of the sentence). It then goes on to further restrict what the implemenation can define (saying it must support two different signatures, without limiting it to supporting those two).
– Yakk - Adam Nevraumont
Nov 23 '18 at 19:14
I would say that your previous comment makes sense to me. But I don't agree that anyone (including native English speakers) could arrive at this conclusion, just by reading the standard.
– WaldB
Nov 23 '18 at 19:26
@WaldB Probably the fact that "shall" has a very specific meaning in ISO standards might have tripped you up.
– Yakk - Adam Nevraumont
Nov 23 '18 at 19:37
Could you comment on this specific meaning?
– WaldB
Nov 23 '18 at 19:56
|
show 1 more comment
The quote "but otherwise its type is implementation-defined" could very well refer to the return type of the function, and not to other arguments. At least that was my interpretation.
– WaldB
Nov 23 '18 at 19:12
@WaldB Sure, you misread it. The but clause does not remove the "shall" requirement from the first part of the phrase. The type of a function includes its return value, its arguments, and (in later versions of C++) if it is noexcept. Allmainfunctions must returnint(part 1 of sentence), but everything else is implementation defined about its type (part 2 of the sentence). It then goes on to further restrict what the implemenation can define (saying it must support two different signatures, without limiting it to supporting those two).
– Yakk - Adam Nevraumont
Nov 23 '18 at 19:14
I would say that your previous comment makes sense to me. But I don't agree that anyone (including native English speakers) could arrive at this conclusion, just by reading the standard.
– WaldB
Nov 23 '18 at 19:26
@WaldB Probably the fact that "shall" has a very specific meaning in ISO standards might have tripped you up.
– Yakk - Adam Nevraumont
Nov 23 '18 at 19:37
Could you comment on this specific meaning?
– WaldB
Nov 23 '18 at 19:56
The quote "but otherwise its type is implementation-defined" could very well refer to the return type of the function, and not to other arguments. At least that was my interpretation.
– WaldB
Nov 23 '18 at 19:12
The quote "but otherwise its type is implementation-defined" could very well refer to the return type of the function, and not to other arguments. At least that was my interpretation.
– WaldB
Nov 23 '18 at 19:12
@WaldB Sure, you misread it. The but clause does not remove the "shall" requirement from the first part of the phrase. The type of a function includes its return value, its arguments, and (in later versions of C++) if it is noexcept. All
main functions must return int (part 1 of sentence), but everything else is implementation defined about its type (part 2 of the sentence). It then goes on to further restrict what the implemenation can define (saying it must support two different signatures, without limiting it to supporting those two).– Yakk - Adam Nevraumont
Nov 23 '18 at 19:14
@WaldB Sure, you misread it. The but clause does not remove the "shall" requirement from the first part of the phrase. The type of a function includes its return value, its arguments, and (in later versions of C++) if it is noexcept. All
main functions must return int (part 1 of sentence), but everything else is implementation defined about its type (part 2 of the sentence). It then goes on to further restrict what the implemenation can define (saying it must support two different signatures, without limiting it to supporting those two).– Yakk - Adam Nevraumont
Nov 23 '18 at 19:14
I would say that your previous comment makes sense to me. But I don't agree that anyone (including native English speakers) could arrive at this conclusion, just by reading the standard.
– WaldB
Nov 23 '18 at 19:26
I would say that your previous comment makes sense to me. But I don't agree that anyone (including native English speakers) could arrive at this conclusion, just by reading the standard.
– WaldB
Nov 23 '18 at 19:26
@WaldB Probably the fact that "shall" has a very specific meaning in ISO standards might have tripped you up.
– Yakk - Adam Nevraumont
Nov 23 '18 at 19:37
@WaldB Probably the fact that "shall" has a very specific meaning in ISO standards might have tripped you up.
– Yakk - Adam Nevraumont
Nov 23 '18 at 19:37
Could you comment on this specific meaning?
– WaldB
Nov 23 '18 at 19:56
Could you comment on this specific meaning?
– WaldB
Nov 23 '18 at 19:56
|
show 1 more comment
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53451711%2fisnt-the-note-below-a-contradiction-in-relation-to-paragraphs-2-1-and-2-2-i%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
It says an implementation shall allow both, but not only both.
– Neil Butterworth
Nov 23 '18 at 18:56
2
Why do you feel this is a contradiction?
– Nicol Bolas
Nov 23 '18 at 18:57
1
Please specify what exactly you consider the contradiction. It is not clear to me how you interpret the mentioned parts of the quote.
– user10605163
Nov 23 '18 at 18:59