compiler-warnings | A list of compiler warning flags for different GCC and clang versions | Compiler library
kandi X-RAY | compiler-warnings Summary
kandi X-RAY | compiler-warnings Summary
A list of compiler warning flags for different GCC and clang versions
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Parse options file
- Parse warning blocks
- Apply a listener to the given string value
- Return True if the option is a warning option
- Print warning flags
- Check if a switch is a dummy switch
- Prints enabled options
- Create dummy text
- Print the references to the switch
- Adds common options
- Check if switch is a root class
- Create dummy text for a dummy switch
compiler-warnings Key Features
compiler-warnings Examples and Code Snippets
Community Discussions
Trending Discussions on compiler-warnings
QUESTION
This morning I created an MSTest project in C#, and for one of the JSON resources, Visual Studio is showing this warning:
...ANSWER
Answered 2021-Feb-02 at 17:38Apparently all you have to do is to close out the file. It seems to only show when the file is opened.
Perhaps a later version of Visual Studio can make this warning behave more consistently with a standard warning in VS. Really it behaves very much like a refactoring / code cleanup suggestion (which commonly has a grey, squiggly line), rather than an actual warning. It's like it's just been mislabeled in development or whatever. However the good thing is that as long as the file is closed, it doesn't pollute the build or the errors window with warning messages.
QUESTION
Where are the NVCC codes for a specific warning listed?
Looking at other questions like this one gives the answer to use -Xcudafe "--diag_suppress=xxx
to suppress warning "xxx", and links to a list of possible warnings here.
However, when I have the warnings
/usr/include/eigen3/Eigen/src/Core/util/XprHelper.h(94): warning: __host__ annotation is ignored on a function("no_assignment_operator") that is explicitly defaulted on its first declaration
and
/usr/include/eigen3/Eigen/src/Core/util/XprHelper.h(94): warning: __device__ annotation is ignored on a function("no_assignment_operator") that is explicitly defaulted on its first declaration
I do not find that type in the list. Can someone point me to the page where it is, so I can find the code/name of it? I did not find it in the documentation for NVCC.
...ANSWER
Answered 2021-Apr-08 at 02:37Where are the NVCC codes for a specific warning listed?
They are not publicly available. There is no list. There is no straightforward way of doing what you want without some combination of:
- Promoting all warnings to errors and forcing the device front end/compiler to emit error codes not textual messages, and then
- Snooping around in the EDG front end documentation and the files and documented distributed by other compilers which also use the EDG front end to see if you can find a matching code, otherwise
- Dumping strings and snooping around in the cudafe executable to see if you can find the string you are looking for, and then see if you can reverse engineer back to a warning code or enumeration
In short, you really have to want this badly and have time to invest, and even then it might not be possible.
Alternatively, register in the NVIDIA developer program, raise a bug and see if they will help you with the information you need.
QUESTION
I do not understand why an exception is constantly thrown when, during line-by-line debugging, it does not even enter the function.
My code:
...ANSWER
Answered 2021-Apr-02 at 10:42[...] it does not even enter the function.
That's true, because num2 = -2
, the string "Your base num less than zero"
is thrown but it's not caught, throwing strings around is not something one would recommend. I suggest you wrap it in an actual exception and throw it instead.
The conditions will be as follows:
QUESTION
When using Trompeloeil to mock unit tests in C++, how can use an unordered_map
as a return type?
ANSWER
Answered 2021-Jan-20 at 14:52Templated return types need to be wrapped in (...)
. This is explained in: Q. Why can't I mock a function that returns a template?
QUESTION
In Visual Studio, warning C4996 (using a deprecated function) is treated as an error, and code that uses deprecated functions doesn't compile at all.
There are various ways to disable C4996 entirely, either suppressing it for a single line, for a translation unit, or for an entire project. But what if I want it to still raise a warning, but allow compilation while not treating it as an error?
...ANSWER
Answered 2021-Feb-02 at 05:52Found a working solution. It turns out the relevant flag is actually "SDL checks", not "Treat Warnings as Errors". Flipping it from /sdl
to /sdl-
causes compilation to emit a warning while still compiling.
EDIT: If I want to keep all the SDL checks on except treating Warning C4996 as an error, I can use the flag /sdl
in combination with the flag /w34996
, which specifies that 4996
is treated as a level 3 warning instead of an error.
QUESTION
I'd like to have a warning similar to -Wsign-compare
in msvc. E.g. it should trigger for:
ANSWER
Answered 2020-Aug-16 at 11:23There is an (apparently) undocumented warning C4388 that will be shown for your code, which is very similar to the documented C4389.
The following code, compiled with the /W4
switch generates each of these two warnings:
QUESTION
Visual Studio is able to warn a user when certain type casts are impossible such as below
...ANSWER
Answered 2020-Aug-14 at 18:36This is not possible as a general solution (a custom analyzer can be written for specific cases though, such as your OfType
example).
It's also not necessary though. The compiler error in your first example prevents a runtime InvalidCastException
, and in your second example the warning indicates a predicate that's always false
, and therefore any code in that if
statement is unreachable - usually not the intent.
The OfType
call has no possibility of a runtime failure. While there may be a minor performance benefit in your OfType
example (as the check will invariably return an empty enumeration), since LINQ is lazily evaluated, the real performance benefit would be very minor, if any; but the requirement for the compiler to understand the method's innner workings to accomplish such task, is ...insanely hard to implement correctly! Compilers, even really advanced ones today, haven't learned to do that.
So, not possible, but that might be ok.
QUESTION
In the first paragraph cppreference.com clearly states that throw(T1, ..., Tn)
is removed in C++17.
It confuses me, that some compilers support throw(T1, ..., Tn)
in C++17 mode (see demo).
- MSVC supports it by default, but you can turn on a warning for it, see C5040. It can be turned into an error with
/we5040
. - Clang reports it as an error by default, but the error can be turned off with
-Wno-dynamic-exception-spec
. - GCC leaves you with no choice: it's an error.
Are compilers allowed to support a feature, that is removed in the standard? For what purpose?
Or is this just a compiler extension, like void foo(int size) { char a[size]; }
in GCC, see demo.
ANSWER
Answered 2020-Aug-03 at 17:52Are compilers allowed to support a feature, that is removed in the standard?
The standard doesn't allow that. AFAIK in general it doesn't give any special treatment to features that used to be in the language (doesn't separate them from non-existent features).
If a compiler doesn't diagnose this error (i.e. doesn't give an error or a warning) with a specific configuration (i.e. specific flags), then it doesn't conform to the standard in that configuration.
For what purpose?
Backward compatibility (what else could it be). More specifically, it lets you use both old and new features in a same translation unit.
This can be useful if you're using a library that uses a removed feature in its headers, but want to use the new language features in your own code.
Or if you want to use the removed feature in your own code along with the new features, for some reason.
Note that absolute conformance to the standard is not practically possible to achieve.
Some compiler vendors care about conformance more than the others. Microsoft tends to care less about it (or at least used to, they've been working on that).
QUESTION
I have a requirement to allocate a block of contiguous memory space of size only storable in a LONGLONG (long long)
container. A warning of type C4244
is thrown by the compiler when a LONGLONG
value is used with the new
statement or malloc()
function, stating that there is a possible loss of data when converting from LONGLONG
to size_t
(in the case of malloc()
) or unsigned int
(in the case of new
).
I am using the Visual C++ compiler.
Thanks in advance.
...ANSWER
Answered 2020-Jul-03 at 03:48The stated warning only persisted as the code was set to compile to the x86 instruction set, in which no more than 4 GB of memory can be used. As in any (and every) case/instance, it is impossible to allocate contiguous memory beyond the range of SIZE_T
which makes the range of the size datatype of the x64 architecture wider than that of the x86 (32-bit) architecture.
QUESTION
MSVC emits warning C4090 about const correctness while both GCC and Clang accept it : Compiler Explorer.
...ANSWER
Answered 2020-Jun-08 at 10:32You can disable this warning right before the line which invokes it and restore it back afterwards https://godbolt.org/z/W-XR-Q:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install compiler-warnings
You can use compiler-warnings like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page