Questions tagged [compiler-warnings]

1

votes
0

answer
7

Views

How to disable “unnecessary path disambiguator” warning?

I am generating code with a macro, which contains fully qualified type paths like this: let vec: Vec::; Note the extra :: before . This is necessary so that the same input token can be also be used for the constructor, by appending ::new(): Vec::::new() However, this produces warnings: warning: unne...
0

votes
1

answer
14

Views

Will -Wpedantic do anything when compiling with a non-extension -std?

If I compile my C or C++ code with GCC, using -std=c99 or -std=c++11 or some other proper ISO standard rather than a GNU extension - will -Wpedantic issue more warnings that I would usually get? e.g. With -W, -Wall or -Wall -Wextra?
einpoklum
1

votes
1

answer
43

Views

How can I disable compiler warnings regarding certain library?

I'm using CLion as my IDE. I downloaded MinGW from here (comes with boost), extracted, installed and connected it to CLion successfully. Then I set my compiler flags in CMakeLists and when I compiled my program, I encounted hundreds of warnings coming from boost libraries (in this case - boost/lexic...
Fureeish
1

votes
1

answer
113

Views

suppress warnings on multiple compiler builds

Is there a generic suppress warning that i can use? The problem is that there are times i may build using one compiler version (gcc) and then i have a partner that uses some of the common things but uses a different compiler. So the warning # are different. The only way i could think of doing was m...
Jtello
1

votes
2

answer
3.1k

Views

Property type '' is incompatible with type '' inherited from ''

I created a BaseRequest Class and it has a property conformed BaseParams protocol. and next I created a DiagramReqesut Class inherited from BaseRequest and it has a property whose type is DiagramParam conformed BaseParams protocol as well. I think it is safe for compiling, but xcode still warn that:...
Feather
1

votes
2

answer
3.5k

Views

CppUnit expect exception with Assert Throw compiles with warning C4127 [duplicate]

This question already has an answer here: do while(false) pattern [duplicate] 7 answers Currently I am writing unit tests in C++ with CppUnit. Recently I needed to check that an exception is thrown in a specific case using CppUnits macro: CPPUNIT_ASSERT_THROW( boost::get(m_boostVariantFooOrBar), bo...
Hannes M
1

votes
1

answer
1.3k

Views

CodeWarrior compiler warning: “Possible loss of data”

Please consider the following code: unsigned int beta; unsigned int theta; unsigned int m = 4; unsigned int c = 986; unsigned int Rpre = 49900; unsigned int getUAnalog(unsigned char channel) // to get the PT1000 Signal { unsigned int result; unsigned int f_temp; //select channel and initiate conver...
sheetansh
1

votes
1

answer
71

Views

Pointer to character array

I have a linked list that looks like this typedef struct list { int num; int *ptr; struct history * next; }history; I also have a character array char *args[MAX_LINE/2+1]; I want to set the pointer *ptr in my linked list to the array args[] to do so I did this history->ptr = args; However, when I...
ab91
1

votes
2

answer
2.1k

Views

error in yacc: ''x' has no declared type

I want to run the following .y code for constructing a C compiler. The code was taken exactky from this Book The following miniC.y code is: %{ #include #include "mini.h" #include "miniC.h" %} %union { ADDRESS address; int code; /* comparison code 1-6 */ struct {int L1; int L2; int L3; int L4;}...
sabu
1

votes
1

answer
1k

Views

Python: “Unused variable” warning in PyDev

Here is my code, and there is a "compiler" warning (is that the correct term for it?) under the instantiation of normDataSet below: def autoNorm(dataSet): minVals = dataSet.min(0) maxVals = dataSet.max(0) ranges = maxVals - minVals normDataSet = np.zeros(np.shape(dataSet)) # Warning under "normDataS...
modulitos
1

votes
2

answer
96

Views

Avoiding debugger warning in IsNothing() statement

I am using Visual Studio 2012 and have the following code block. The code checks the file type of a specific file (that's why there are return True/False in it). If it encounters an error it also returns false. The warnings I get are that I use the fs/br variables before they are initialized, which...
Jens
1

votes
1

answer
100

Views

Compiler warning for Template case, that should be covered by Template Specialization

During my coding in C++98 I get a strange compiler warning that I do not understand:( See: I have a file TemplateSpecialization.hpp: namespace TemplateNamespace { template T getParam(int param) { return static_cast(param); } } struct A { A () : aaa(10) {} int aaa; template T getAaa() { return Temp...
Sokeks
1

votes
1

answer
408

Views

Why doesn't the C++/CLI compiler generate warnings for Obsolete property calls?

I'm referencing a 3rd party .NET library from some C++/CLI code. My C++/CLI calling code is referencing a property that has been marked Obsolete in a C# library using the Obsolete attribute: // C# External library code using System; namespace ExternalLibrary { public class Dependency { [Obsolete("Pl...
Origameg
1

votes
3

answer
273

Views

How can I create custom compiler warnings in java?

I'm looking for something that's similar to implementing the java.lang.AutoCloseable interface, where a compiler warning indicating Resource leak: 'xxxx' is never closed is generated. The use case for this is in a wrapper around a Synchronized Collection in java. The wrapper has an internal semapho...
petesavitsky
1

votes
3

answer
483

Views

Enable compiler warnings for implicit conversions (C#) [duplicate]

This question already has an answer here: How to be warned about potential arithmetic errors due to type conversion? 2 answers Is there any way to enable compiler warnings for implicit conversions in C#? Recently been debugging for over an hour until I realized I had the following code: double = in...
Didii
1

votes
1

answer
1.4k

Views

Prevent ObsoleteAttribute warning bubbling up call stack

I have a class using a deprecated assembly (System.Data.OracleClient). At compile time this results in a message 'MethodName()' is obsolete: 'OracleConnection has been deprecated. We can't replace this assembly and we are now trying to remove all warnings generated at compile time so that new warnin...
Badgerspot
1

votes
2

answer
166

Views

Why doesn't the compiler warn about unsigned to signed conversion?

I recently got bit in the butt with this code: std::size_t s = 10; std::vector v{s}; Rather than initialize with a size of 10, this initializes with a size of 1 with one element 10. However, the vector has an explicit constructor that takes a std::size_t. With all the hype about "use braces everywhe...
user5389903
1

votes
2

answer
1.3k

Views

How to disable “Missing XML comment” warning for auto generated code in Windows Store app?

I get numerous compiler warnings CS1591 Missing XML comment for publicly visible type or member ... in my Universal Windows Store App project in VS2015 for auto generated code files, e.g. App.g.cs App.g.i.cs SomePage.g.cs SomePage.g.i.cs I know of the different approaches available to fix these warn...
Gorgsenegger
1

votes
2

answer
307

Views

[[maybe_unused]] on member variable, GCC warns (incorrectly?) that attribute is ignored

In the following example: struct Foo { [[maybe_unused]] int member = 1; void bar() { [[maybe_unused]] int local = 0; } }; int main(int argc, char* argv[]) { Foo f{}; f.bar(); return 0; } GCC emits a warning where Clang and MSVC do not: warning: 'maybe_unused' attribute ignored [-Wattributes] [[maybe...
0x5453
1

votes
1

answer
1.2k

Views

Why is warning disable 429 not working to surpress unreachable code?

I am trying to suppress a warning in a very simple C# file, but it is not working and I cannot find what I am doing wrong here. Why is Visual Studio still showing "Unreachable code detected" in this small piece of code. #pragma warning disable 429 // I've got the number from: // http://msdn.microsof...
JaJa
1

votes
2

answer
76

Views

Why is `int` datatype not mandatory to be mentioned for function arguments in the function definition?

Recently I went through some code similar to this: (The code is proprietary, and hence adding a similar one) #include void test_it(var) { printf("%d\n",var); } int main() { test_it(67); return 0; } The arguments of test_it do not have datatype mentioned. I compiled it as gcc test_it.c... : Surprisin...
1

votes
2

answer
110

Views

How can a wrong assumption on operator precedence be corrected in order to remove the side effects of the code?

While reviewing someone's code, I have encountered a situation similar to this following one where the error (which is basically some poor programming practice) is not quite directly visible. Depending on the compiler used, i/i++ might be either 0 or 1. int foo(int n) { printf("Foo is %d\n", n); ret...
George Netu
1

votes
2

answer
2k

Views

Recipes on how to supress / fix “Implicit conversion changes signedness” warning

I'm modernizing a legacy project and I enabled -Wconversion flag on Xcode. Now I have a lot of warning like Implicit conversion changes signedness: 'NSUInteger' (aka 'unsigned long') to 'NSInteger' (aka 'long') using code like the following while interacting with a UITableView Item *item = [self.ite...
Lorenzo B
2

votes
2

answer
51

Views

Does -Werror interfere with template correctness and/or SFINAE?

I have the feeling that this is a dumb question and I guess that the answer is a simple "No", though I have no clue how to be certain about it other than asking for your help... Does -Werror interfere with template correctness (not sure what is the right term, see example below) and/or SFINAE? Consi...
user463035818
1

votes
2

answer
56

Views

Compiler not showing warning messages for explicit casts

I have recently downloaded the MinGw compiler and for some reason it does not display and warning messages when I should be doing a explicit casts. For example: double x=9.97; int y=x; This seems to be ok with the compiler. I was just wondering do I need to install some other package
user3223190
1

votes
2

answer
685

Views

Why is Elixir warning me that my import is unused?

I'm new to Elixir and encountered this. It does not make any sense to me, so I'm probably missing something. Why is Elixir giving me this warning: lib/test.ex:3: warning: unused import on that code defmodule Test do def run(str) do import Poison obj = Poison.Parser.parse!(str) obj = %{obj | "name" =...
sam-i-am
1

votes
3

answer
167

Views

Silencing -Wunused-variable in an if statement

The following code generates a warning that temp is not used (which is true): #include int f() { return 5; } int main() { if(const int& temp = f()) { printf("hello!\n"); } return 0; } The thing is that I NEED to do this without generating a warning with gcc -Wall and clang -Weverything (I'm impleme...
onqtam
1

votes
2

answer
47

Views

How to address a float to write 4 individual bytes to it in C?

I have a function that expects a 32 bit float, however in a certain mode it expects the float to actually just be 4x UINT8s packed together. The code I have written works however I get a compiler warning "illegal pointer" warning and I want to know what is the most "correct" way to do it? Code reada...
rolls
2

votes
1

answer
684

Views

Enable C++ compiler warning for missing XML documentation

When XML documentation is enabled for my C++ projects (managed) the compiler does not raise any warnings for missing comments. I have enabled the documentation generation by setting "Generate XML documentation Files" (/doc) to true as described here. The project is configured as a dynamic library wi...
Simon Fischer
2

votes
3

answer
1.3k

Views

Warning C4710 (not inlined) with inherited destructors

I have 3 classes that build a chain of inheritance. Two of the classes are pure abstract (IProxy and IDataProxy), the third one really "does the work" (DataProxy). The classes are the following (only showing con/destructors here): IProxy: class __declspec(dllexport) IProxy { public: IProxy() {} virt...
Baldewin
1

votes
1

answer
1.5k

Views

Swift result of call to is unused [duplicate]

This question already has an answer here: Result of call to [myFunction] is unused 2 answers I cant figure out how to remove this warning in swift3: Result of call to 'responseMessagesArray' is unused This is how my code looks like: fileprivate class func getMessagesAtPath(_ path: String, tokenKey:...
user2636197
1

votes
6

answer
89

Views

Why can I compile a code with 2 returns?

Since am comming from a java island, I wounder why the compiler doesnt warns about unreachable code in something like: int main(int argc, char** argV) { std::list lst = {1,2,3,4}; return 0; std::cout
Firewall-Alien
4

votes
2

answer
15.7k

Views

C Returning char[] Warning “returns address of local variable” [duplicate]

This question already has an answer here: Returning an address of local variable behaviour [duplicate] 2 answers This is a portion of a homework assignment. I am trying to read and return a single line of a file in my method getLine. char *getLine(FILE *input) { char line[30]; if(fgets(line, sizeof...
haloid2010
6

votes
3

answer
198

Views

What legal code could trigger C4523 “multiple destructors specified” Visual C++ warning?

According to MSDN, Visual C++ can emit C4523 warning 'class' : multiple destructors specified. How is such situation even possible? I tried the following: class Class { ~Class(); ~Class(int); }; which yields a destructor must have a 'void' parameter list error and C4523 warning and the following cla...
sharptooth
2

votes
2

answer
844

Views

type of 'USART0_RX_vect' defaults to 'int' [enabled by default]

Learning AVR C programming i end up getting a warning from int ISR(USART0_RX_vect) { // blah blah blah... return 0; } //Warning 1 type of 'USART0_RX_vect' defaults to 'int' [enabled by default] Why is this warning appearing and what actions are required to remove it?
wittrup
3

votes
2

answer
576

Views

C Enum Warnings

I'm updating a physics simulation C code to use enums from long lists of #defines, but have run into an odd bug. A structure contains an enum as: enum spec_mod_type_enum { SPEC_MOD_PL=1, SPEC_MOD_EXP=2, } spec_mod_type[NXBANDS]; (NXBANDS is just a #defined value) Due to an oversight, no key is add...
Toaster
17

votes
3

answer
438

Views

What Scala annotations modify the compiler's messages?

I know about two: @deprecated("use blabla instead") is used to add an explanation to the warning output by the compiler when the annotated definition is used in client code. @implicitNotFound(msg = "more meaningful explanation") is used to output an additional error message whenever an implicit of t...
Jean-Philippe Pellet
17

votes
7

answer
9.7k

Views

Making GCC and Other C++ Compilers Very Strict

I'm working on a large collaborative C++ project that is both developed and run on various flavors of Linux, OS X and Windows. We compile across these platforms with GCC, Visual Studio C++ and the Intel C++ compiler. As more and more people start developing code for the project, we're starting to se...
James Thompson
17

votes
3

answer
1.1k

Views

Why the compiler does not issue a warning when an object std::vector is declared but never used? [duplicate]

This question already has an answer here: A variable not detected as not used 3 answers #include class Object { }; int main() { Object myObject; std::vector myVector; } Compiler emits: warning: unused variable 'myObject' [-Wunused-variable] No warning for myVector. Why? Is there any way to enable...
Jovini
1

votes
3

answer
1.3k

Views

objective-c Derived class may not respond to base class method

I have derived from a 3rd party class, and when I attempt to call a method in the base class, I get the x may not respond to y compiler warning. How can I remove the warning? Repro: @interface ThirdPartyBaseClass : NSObject {} +(id)build; -(void)doStuff; @end @implementation ThirdPartyBaseClass +(id...
zadam

View additional questions