compiler-warnings

warning C4172: returning address of local variable or temporary [duplicate]

混江龙づ霸主 提交于 2020-01-03 02:29:24
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Pointer to local variable I've read a lot of other topics on this site about the same problem knowing it would be common. But I guess I'm dumb and can't figure out the proper way to do it. So, I apologize for yet another one of these questions and I'm hoping someone can give me a simple solution and/or explanation. Here's the entire code: Main.c #define WIN32_LEAN_AND_MEAN #include <Windows.h> #include <stdlib.h

“warning: initialization makes pointer from integer without a cast”. But I don't think it does

♀尐吖头ヾ 提交于 2020-01-02 08:03:43
问题 I'm getting a strange compile warning. It's intermittent, and doesn't appear every build. I get the warning "initialization makes pointer from integer without a cast" for the following line: callbackTable *callbacks = generateLoggingCallback(); and, for completeness, this gives the same outcome callbackTable *callbacks; callbacks = generateLoggingCallback(); the function prototype for that is: callbackTable *generateLoggingCallback(); and the implementation is callbackTable

Eclipse Warnings: class javax.persistence.* not found

别来无恙 提交于 2020-01-02 07:04:21
问题 This is my first time really playing around with Java development using Eclipse. I am trying to use EclipseLink's implementation of the JPA. I moved all of my entities into a separate package "entities". I have the persistence.xml in a separate JPA project called "dataModeling". Everything builds and runs fine. Just about every project depends on my entities. However, I'm seeing a warning Class javax.persistence.Entity not found - continuing with a stub. , etc. showing up because the

Disadvantages of using the `-Wextra` flag when compiling in GCC

我怕爱的太早我们不能终老 提交于 2020-01-02 01:56:49
问题 I know that one should always compile with both -Wall and -Wextra as they enable warnings and help us to understand our mistake, if any. I've read that the -Wextra compiler flag is not recommended to use because it is too verbose with a lot of false positives. I was quite surprised on reading this. So I started googling about it but I didn't get any answer as all the search results showed was "what does the -Wextra flag do?". So, my questions are In which all situations does the -Wextra flag

Why does GCC warn against this implicit conversion?

久未见 提交于 2020-01-02 01:53:07
问题 GCC warns me that the following piece of code contains an implicit conversion that may change a value: #include <stdlib.h> float square = rand(); However, the following does not yield any warning: float square = 100; The warning given by GCC is a follows: tests/ChemTests.cpp:17:23: error: conversion to ‘float’ from ‘int’ may alter its value I don't understand why the former would give a warning, since rand() is properly declared and returns an int , just as the 100 integer literal. Why does

“warning: __host__ annotation on a defaulted function is ignored” <- why?

北战南征 提交于 2020-01-01 11:37:10
问题 Switching from CUDA 8.0 to CUDA 9.0 RC, I get a warning about: __host__ __device__ ~Foo() = default; The warning is: path/to/Foo.cuh(69): warning: __host__ annotation on a defaulted function("~Foo") is ignored which I didn't use to get before. Should I really be getting this warning? What's wrong with indicating you want the default destructor on both the device and the host side? 回答1: What's wrong with indicating you want the default destructor on both the device and the host side? But that

Does casting a char array to another type violate strict-aliasing rules?

╄→尐↘猪︶ㄣ 提交于 2020-01-01 08:27:08
问题 Consider these two functions: int f1() { alignas(int) char buf[sizeof(int)] = {}; return *reinterpret_cast<int*>(buf); } int f2() { alignas(int) char buf[sizeof(int)] = {}; char* ptr = buf; return *reinterpret_cast<int*>(ptr); } GCC warns that the first violates strict-aliasing rules. But the second is OK. Clang accepts both without complaint. Is the warning legitimate? 回答1: The warning is legitimate. f2 is not OK (it is undefined behaviour), it just doesn't provoke the warning. I suspect the

Java: complete list of @SuppressWarnings(…) parameters (in Netbeans)?

自闭症网瘾萝莉.ら 提交于 2020-01-01 02:17:06
问题 Netbeans provides a lot of custom "hints", which are like warnings, only that most of them can't be suppressed (just disabled IDE-globally). But now I looking at code which uses @SuppressWarnings("element-type-mismatch") to suppress a hint/warning which is called "suspicious method call" (such as remove(...) for a collection with a "wrong" type). Well, I would never come to the idea to suppress a hint named "suspicious method call" with a SuppressWarnings -parameter called "element-type

C++: 'cout << pointer << ++pointer' generates a compiler warning

萝らか妹 提交于 2019-12-30 18:27:13
问题 I have a C++ learning demo here: char c = 'M'; short s = 10; long l = 1002; char * cptr = &c; short * sptr = &s; long * lptr = &l; cout << "cptr:\t" << static_cast<void*>(cptr) << '\n'; cout << "cptr++:\t" << static_cast<void*>(++cptr) << '\n'; cout << "sptr:\t" << sptr << '\n'; cout << "sptr++:\t" << ++sptr << '\n'; cout << "lptr:\t" << lptr << '\n'; cout << "lptr++:\t" << ++lptr << '\n'; cout << c << '\t' << static_cast<void*>(cptr) << '\t' << static_cast<void*>(++cptr) << '\n'; cout << s <

C++: 'cout << pointer << ++pointer' generates a compiler warning

独自空忆成欢 提交于 2019-12-30 18:27:04
问题 I have a C++ learning demo here: char c = 'M'; short s = 10; long l = 1002; char * cptr = &c; short * sptr = &s; long * lptr = &l; cout << "cptr:\t" << static_cast<void*>(cptr) << '\n'; cout << "cptr++:\t" << static_cast<void*>(++cptr) << '\n'; cout << "sptr:\t" << sptr << '\n'; cout << "sptr++:\t" << ++sptr << '\n'; cout << "lptr:\t" << lptr << '\n'; cout << "lptr++:\t" << ++lptr << '\n'; cout << c << '\t' << static_cast<void*>(cptr) << '\t' << static_cast<void*>(++cptr) << '\n'; cout << s <