compiler-warnings

Using typecasting to remove gcc compiler warnings

家住魔仙堡 提交于 2019-12-23 07:28:56
问题 I am doing embedded ARM programming with gcc 4.9. I've been using the -Wconversion switch because it's in my company's default dev tool configuration. I'm using the stdint.h types (uint8_t, uint32_t, etc). The compiler creates warnings every time I perform a compound assignment or even simple addition. For example: uint8_t u8 = 0; uint16_t u16; // These cause warnings: u8 += 2; u8 = u16 >> 8; The "common method" to fix this is to use casts, as discussed here and here: u8 = (uint8_t)(u8 + 2);

Why is returning address of local variable or temporary only a warning and not an error?

一曲冷凌霜 提交于 2019-12-23 06:48:56
问题 Having just received a warning from the compiler for this function: template<class T> Matrix3x3<T> & operator - (Matrix3x3<T> const & p) { auto m = Matrix3x3<T>(p); m.m11 = -m.m11; m.m12 = -m.m12; m.m13 = -m.m13; m.m21 = -m.m21; m.m22 = -m.m22; m.m23 = -m.m23; m.m31 = -m.m31; m.m32 = -m.m32; m.m33 = -m.m33; return m; } , I am wondering why returning an address of local variable or temporary doesn't merit an error. Are there circumstances where you have to do it? What's the rationale for this

-Wunused-variable compiler says ERROR

狂风中的少年 提交于 2019-12-23 06:06:18
问题 Recently I'm starting to program in C + + (I come from Java, and it costs me a little change haha). Under Windows everything right. The problem is that I switched to Linux and this is where I have problems with the compiler. It is usually when you declare a variable and is not used, the compiler displays a "warning" saying that the variable is not used, but I (under linuxmint 15) throws me as "error" and leaves no compile: C. I do not know if anyone has this happened, but I'm sick at the time

Swift use 'is' for function type, compiler behavior is different with runtime

大憨熊 提交于 2019-12-23 04:45:10
问题 I am testing about function is first class citizen in Swift. and I got in trouble. Check the code below: let f: Int -> Int = { $0 } if f is (Int -> Int?) { // compiler warning: 'is' test is always true print("hello") } else { print("ops") // runtime: this line is executed } I got a compiler warning in the if line says: "'is' test is always true". But when I run the code, console print "ops" which means is test is false. This confuses me. Why compiler says true when runtime says false? 来源:

cc1plus: unrecognized command line option warning on any other warning

亡梦爱人 提交于 2019-12-23 02:38:35
问题 I have a strange behavior of g++ that it shows a warning about unrecognized command line option, when any other warning is shown. Example: struct Foo{virtual int bar() = 0;}; struct Bar:public Foo{int bar() {return 0;} }; int main(){} Compiling with g++-5 -Wsuggest-override -Wno-c99-extensions -std=c++11 a.cpp or even g++-5 -Wsuggest-override -Wno-c99-extensions a.cpp shows: a.cpp:2:27: warning: ‘virtual int Bar::bar()’ can be marked override [-Wsuggest-override] struct Bar:public Foo{int bar

warning: assignment from incompatible pointer type for linklist array

家住魔仙堡 提交于 2019-12-22 18:25:23
问题 I am executing a C program where I am getting warning: warning: assignment from incompatible pointer type I am copying related code herein: //Structure I am using: typedef struct graph_node { int id; int weight; struct node *next; }node, dummy; node *head[10]; // Function which is generating this warning: void print_list() { int i; for (i = 0;i< vertex; i++) { printf ("\n ==>>%d ", head[i]->id); while (head[i]->next != NULL) { head[i] = head[i]->next; printf ("\t ==>>%d ", head[i]->id); /****

how to make g++ generate an error/warning for int i = i?

穿精又带淫゛_ 提交于 2019-12-22 11:27:22
问题 I had a hard time to find a bug in my code caused by a loop like this: for (int i=i;i<5;i++){ // ... } I use g++ 4.7.2 with -O2 -Wall , but no warning/error is shown. Is there some compiler flag that also in combination with -O2 creates a warning for such a case? I found several related questions: here in the comments it is discussed, that g++ shows a warning with -Wall when there is no -O2 . However, that question is particular because the problematic loop is optimized away with -O2 which

Scala: comparing fresh objects

老子叫甜甜 提交于 2019-12-22 10:57:40
问题 I was browsing scala tests and I don't understand why the compiler produces a warning when you compare "two fresh objects". This is the test' outputs: http://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/test/files/neg/checksensible.check Example: checksensible.scala:12: warning: comparing a fresh object using `!=' will always yield true println(new Exception() != new Exception()) ^ If I write a class implementing an == method it will also produces this warning: class Foo(val bar: Int) { def

c++ Builder xe5 Error detected (LME288)

馋奶兔 提交于 2019-12-22 04:56:35
问题 c++ Builder xe5 [ilink32 Error] Error: Unable to perform link [ilink32 Warning] Warning: Error detected (LME288) that happened when i tried to compile a test project c++ builder xe5 on windows xp 回答1: I got some information on this from Embarcadero which may help. The error is an "out of memory", error. The reason for "Out Of Memory" errors (which come in different guises) in the linker, is that the linker has to pre-allocate memory in contiguous heaps that it then uses as it links, in the

c++ Builder xe5 Error detected (LME288)

我怕爱的太早我们不能终老 提交于 2019-12-22 04:56:05
问题 c++ Builder xe5 [ilink32 Error] Error: Unable to perform link [ilink32 Warning] Warning: Error detected (LME288) that happened when i tried to compile a test project c++ builder xe5 on windows xp 回答1: I got some information on this from Embarcadero which may help. The error is an "out of memory", error. The reason for "Out Of Memory" errors (which come in different guises) in the linker, is that the linker has to pre-allocate memory in contiguous heaps that it then uses as it links, in the