How to enable _all_ warnings with -fpermissive from g++?
There seem to be cases where the -fpermissive option results in errors being ignored altogether, rather than "downgraded" to warnings, as widely available documentation suggests.
The -Wall option is clearly not enough. What other options are needed in order to have all such downgraded warnings reported by g++?
An example came up with the Nodejs C++ addon library.
In file included from /opt/nodejs/linux64/8.9.4/include/node/node.h:63:0,
from /opt/nan/linux64/2.9.2/include/nan.h:51,
from /build/ndjs/include/blob.h:59,
from /build/ndjs/src/blob.cpp:2:
/opt/nodejs/linux64/8.9.4/include/node/v8.h: In instantiation of ‘v8::Local<T>::Local(v8::Local<S>) [with S = v8::Integer; T = v8::Int32]’:
/build/src/ndjs/blob.cpp:507:1: required from here
/opt/nodejs/linux64/8.9.4/include/node/v8.h:207:5: error: invalid conversion from ‘v8::Integer*’ to ‘v8::Int32*’ [-fpermissive]
TYPE_CHECK(T, S);
^
Recompiling with -fpermissive (and -Wall, of course) results in a clean compile: no warnings at all. What happened? (i.e. Why?)
The TYPE_CHECK() macro tests for type compatibility in pointer assignments:
#define TYPE_CHECK(T, S)
while (false) {
*(static_cast<T* volatile*>(0)) = static_cast<S*>(0);
}
It fails for downcasts (v8::Int32 is derived from v8::Integer), but somehow succeeds without warnings when -fpermissive is in effect. Shouldn't there be a warning about the static downcast?
c++ g++
add a comment |
There seem to be cases where the -fpermissive option results in errors being ignored altogether, rather than "downgraded" to warnings, as widely available documentation suggests.
The -Wall option is clearly not enough. What other options are needed in order to have all such downgraded warnings reported by g++?
An example came up with the Nodejs C++ addon library.
In file included from /opt/nodejs/linux64/8.9.4/include/node/node.h:63:0,
from /opt/nan/linux64/2.9.2/include/nan.h:51,
from /build/ndjs/include/blob.h:59,
from /build/ndjs/src/blob.cpp:2:
/opt/nodejs/linux64/8.9.4/include/node/v8.h: In instantiation of ‘v8::Local<T>::Local(v8::Local<S>) [with S = v8::Integer; T = v8::Int32]’:
/build/src/ndjs/blob.cpp:507:1: required from here
/opt/nodejs/linux64/8.9.4/include/node/v8.h:207:5: error: invalid conversion from ‘v8::Integer*’ to ‘v8::Int32*’ [-fpermissive]
TYPE_CHECK(T, S);
^
Recompiling with -fpermissive (and -Wall, of course) results in a clean compile: no warnings at all. What happened? (i.e. Why?)
The TYPE_CHECK() macro tests for type compatibility in pointer assignments:
#define TYPE_CHECK(T, S)
while (false) {
*(static_cast<T* volatile*>(0)) = static_cast<S*>(0);
}
It fails for downcasts (v8::Int32 is derived from v8::Integer), but somehow succeeds without warnings when -fpermissive is in effect. Shouldn't there be a warning about the static downcast?
c++ g++
1
-fpermissive
is supposed to be used for compiler development / testing purposes, you should never use it to compile regular code and / or expect to get any particular results from doing so.
– VTT
Nov 19 '18 at 16:59
-fpermissive
happened. If you have to tell the compiler to devieate from the standard then you probably need to rethink what your doing in the first place. -Wall is your default.
– johnathan
Nov 19 '18 at 17:36
Instead of trashing -fpermissive, which I can do as well as anyone, please try to address the question: how are downgraded warnings enabled? This comes often when dealing with third party code.
– arayq2
Nov 19 '18 at 17:40
add a comment |
There seem to be cases where the -fpermissive option results in errors being ignored altogether, rather than "downgraded" to warnings, as widely available documentation suggests.
The -Wall option is clearly not enough. What other options are needed in order to have all such downgraded warnings reported by g++?
An example came up with the Nodejs C++ addon library.
In file included from /opt/nodejs/linux64/8.9.4/include/node/node.h:63:0,
from /opt/nan/linux64/2.9.2/include/nan.h:51,
from /build/ndjs/include/blob.h:59,
from /build/ndjs/src/blob.cpp:2:
/opt/nodejs/linux64/8.9.4/include/node/v8.h: In instantiation of ‘v8::Local<T>::Local(v8::Local<S>) [with S = v8::Integer; T = v8::Int32]’:
/build/src/ndjs/blob.cpp:507:1: required from here
/opt/nodejs/linux64/8.9.4/include/node/v8.h:207:5: error: invalid conversion from ‘v8::Integer*’ to ‘v8::Int32*’ [-fpermissive]
TYPE_CHECK(T, S);
^
Recompiling with -fpermissive (and -Wall, of course) results in a clean compile: no warnings at all. What happened? (i.e. Why?)
The TYPE_CHECK() macro tests for type compatibility in pointer assignments:
#define TYPE_CHECK(T, S)
while (false) {
*(static_cast<T* volatile*>(0)) = static_cast<S*>(0);
}
It fails for downcasts (v8::Int32 is derived from v8::Integer), but somehow succeeds without warnings when -fpermissive is in effect. Shouldn't there be a warning about the static downcast?
c++ g++
There seem to be cases where the -fpermissive option results in errors being ignored altogether, rather than "downgraded" to warnings, as widely available documentation suggests.
The -Wall option is clearly not enough. What other options are needed in order to have all such downgraded warnings reported by g++?
An example came up with the Nodejs C++ addon library.
In file included from /opt/nodejs/linux64/8.9.4/include/node/node.h:63:0,
from /opt/nan/linux64/2.9.2/include/nan.h:51,
from /build/ndjs/include/blob.h:59,
from /build/ndjs/src/blob.cpp:2:
/opt/nodejs/linux64/8.9.4/include/node/v8.h: In instantiation of ‘v8::Local<T>::Local(v8::Local<S>) [with S = v8::Integer; T = v8::Int32]’:
/build/src/ndjs/blob.cpp:507:1: required from here
/opt/nodejs/linux64/8.9.4/include/node/v8.h:207:5: error: invalid conversion from ‘v8::Integer*’ to ‘v8::Int32*’ [-fpermissive]
TYPE_CHECK(T, S);
^
Recompiling with -fpermissive (and -Wall, of course) results in a clean compile: no warnings at all. What happened? (i.e. Why?)
The TYPE_CHECK() macro tests for type compatibility in pointer assignments:
#define TYPE_CHECK(T, S)
while (false) {
*(static_cast<T* volatile*>(0)) = static_cast<S*>(0);
}
It fails for downcasts (v8::Int32 is derived from v8::Integer), but somehow succeeds without warnings when -fpermissive is in effect. Shouldn't there be a warning about the static downcast?
c++ g++
c++ g++
edited Nov 19 '18 at 18:03
arayq2
asked Nov 19 '18 at 16:52
arayq2arayq2
1,987916
1,987916
1
-fpermissive
is supposed to be used for compiler development / testing purposes, you should never use it to compile regular code and / or expect to get any particular results from doing so.
– VTT
Nov 19 '18 at 16:59
-fpermissive
happened. If you have to tell the compiler to devieate from the standard then you probably need to rethink what your doing in the first place. -Wall is your default.
– johnathan
Nov 19 '18 at 17:36
Instead of trashing -fpermissive, which I can do as well as anyone, please try to address the question: how are downgraded warnings enabled? This comes often when dealing with third party code.
– arayq2
Nov 19 '18 at 17:40
add a comment |
1
-fpermissive
is supposed to be used for compiler development / testing purposes, you should never use it to compile regular code and / or expect to get any particular results from doing so.
– VTT
Nov 19 '18 at 16:59
-fpermissive
happened. If you have to tell the compiler to devieate from the standard then you probably need to rethink what your doing in the first place. -Wall is your default.
– johnathan
Nov 19 '18 at 17:36
Instead of trashing -fpermissive, which I can do as well as anyone, please try to address the question: how are downgraded warnings enabled? This comes often when dealing with third party code.
– arayq2
Nov 19 '18 at 17:40
1
1
-fpermissive
is supposed to be used for compiler development / testing purposes, you should never use it to compile regular code and / or expect to get any particular results from doing so.– VTT
Nov 19 '18 at 16:59
-fpermissive
is supposed to be used for compiler development / testing purposes, you should never use it to compile regular code and / or expect to get any particular results from doing so.– VTT
Nov 19 '18 at 16:59
-fpermissive
happened. If you have to tell the compiler to devieate from the standard then you probably need to rethink what your doing in the first place. -Wall is your default.– johnathan
Nov 19 '18 at 17:36
-fpermissive
happened. If you have to tell the compiler to devieate from the standard then you probably need to rethink what your doing in the first place. -Wall is your default.– johnathan
Nov 19 '18 at 17:36
Instead of trashing -fpermissive, which I can do as well as anyone, please try to address the question: how are downgraded warnings enabled? This comes often when dealing with third party code.
– arayq2
Nov 19 '18 at 17:40
Instead of trashing -fpermissive, which I can do as well as anyone, please try to address the question: how are downgraded warnings enabled? This comes often when dealing with third party code.
– arayq2
Nov 19 '18 at 17:40
add a comment |
0
active
oldest
votes
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%2f53379298%2fhow-to-enable-all-warnings-with-fpermissive-from-g%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
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%2f53379298%2fhow-to-enable-all-warnings-with-fpermissive-from-g%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
1
-fpermissive
is supposed to be used for compiler development / testing purposes, you should never use it to compile regular code and / or expect to get any particular results from doing so.– VTT
Nov 19 '18 at 16:59
-fpermissive
happened. If you have to tell the compiler to devieate from the standard then you probably need to rethink what your doing in the first place. -Wall is your default.– johnathan
Nov 19 '18 at 17:36
Instead of trashing -fpermissive, which I can do as well as anyone, please try to address the question: how are downgraded warnings enabled? This comes often when dealing with third party code.
– arayq2
Nov 19 '18 at 17:40