compiler-warnings

Is there any C++ compiler which can issue a warning for a dangling reference?

吃可爱长大的小学妹 提交于 2019-12-06 04:39:21
问题 Given the following code, where x is a dangling const reference to a vanished object, and is therefore undefined behavior. auto get_vec() { return std::vector<int>{1,2,3,4,5}; } const auto& x = get_vec().back(); It seems like neither GCC 7.3 , Clang 6.0 and MSVC is able to emit a warning, even with all warnings enabled. Does anyone know if it is any way to emit a warning in these cases? Is there any difference between const auto& and auto&& in these cases? Note, if back() would return by

Scala pattern matching on generic type with TypeTag generates a warning while ClassTag not?

隐身守侯 提交于 2019-12-06 04:32:21
问题 I have two very similar methods. The only difference is the use of ClassTag and TypeTag : def matchClass[A: ClassTag](v: Any) = v match { case a: A => "it's A" case _ => "not A" } def matchType[A: TypeTag](v: Any) = ... // same code as matchClass A compile warning will show for matchType , but not for matchClass : abstract type pattern A is unchecked since it is eliminated by erasure case a: A Why is there a warning? why does it show only for TypeTag and not ClassTag ? 回答1: You don't see a

“Recursive on All Control Paths” error when implementing factorial function

浪子不回头ぞ 提交于 2019-12-06 04:13:11
问题 For class I have an assignment: Write a C++ program that will output the number of distinct ways in which you can pick k objects out of a set of n objects (both n and k should be positive integers). This number is given by the following formula: C(n, k) = n!/(k! * (n - k)!) Your program should use two value-returning functions. The first one should be called factorial and should return n! . The second function should be called combinations and should return n!/(k! * (n - k)!). Test your

Eclipse - @SuppressWarnings(“javadoc”) does not work

半城伤御伤魂 提交于 2019-12-06 03:26:14
问题 I have my Eclipse configured to show warnings on missing javadoc comments and tags for public elements. That comes very usefull for me in order to keep my code well documented. But sometimes I have a class, where I have several constants describing for example states of DFA or something.. theres no need to document theese constant, because they are self-explaining.. So I added annotation @SuppressWarnings("javadoc") to the class and here's my point - Eclipse does not concider the annotation

Potential null pointer access

天涯浪子 提交于 2019-12-06 03:21:54
I encounter a strange situation that is currently not that clear to me: When having the potential null pointer access warning enabled in Eclipse, I get warnings like in the following (the warnings are stick to the line preceding the corresponding comment): protected Item findItemByName(String itemName, Items items) { boolean isItemNameMissing = null == itemName || itemName.isEmpty(); boolean isItemsMissing = null == items || null == items.getItems() || items.getItems().isEmpty(); if (isItemNameMissing || isItemsMissing) { return null; } // potential null pointer access: the variable items

Compile C with function gethostbyname to static linked error

非 Y 不嫁゛ 提交于 2019-12-06 02:31:36
I'm trying compile program using function gethostbyname() with the cross compiler arm-none-linux-gnueabi , but it did not work when I run my binary on android. My code in below: /* gethostbyname-example.c */ #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> extern int h_errno; int main(int argc,char **argv) { int x, x2; struct hostent *hp; for ( x=1; x<argc; ++x ) { hp = gethostbyname(argv[x]); if ( !hp ) { fprintf(stderr, "%s: host '%s'\n", hstrerror(h

How do I know if a Delphi function is going to be inlined?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 01:42:57
问题 When you mark a function as inline , you hint the compiler that this function is a candidate for inlining. The compiler can still decide that it's not a good idea, and ignore it. Is there a way to see if the function gets inlined or not, without using the disassembler? Is there some compiler warning that I don't know about maybe? What are the rules for inlining that the compiler uses? Are there constructs that cause a function to never get inlined for example? 回答1: The compiler emits a hint

Where is this backward_warning.h #warning coming from?

爱⌒轻易说出口 提交于 2019-12-06 00:19:09
问题 Without looking through every single source file in my XCode project, is there a way to find out which #include is triggering the following warning? #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno

Eclipse Warnings: class javax.persistence.* not found

a 夏天 提交于 2019-12-05 21:28:45
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 dependent projects don't reference EclipseLink. The solution is to go into each dependent project's properties

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

核能气质少年 提交于 2019-12-05 21:09:15
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 *generateLoggingCallback() { ... } So, I'm not quite sure what the problem is. Ideas? If it's pure C, isn't there a