gcc-warning

Which gfortran compiler flag is associated with the warning “Illegal preprocessor directive”?

喜夏-厌秋 提交于 2019-12-11 02:53:54
问题 When using pFUnit (3.2.9) to test my Fortran code, I get many "Illegal preprocessor directive" warnings, e.g. Warning: Illegal preprocessor directive /path/to/my/file/test.f90:37:2: #line 26 "/path/to/my/file/test.f90" 1 The code compiles and runs fine, so I would like to turn off these warnings, while still seeing other compiler warnings. Which gfortran compiler flag turns this specific warning off? I am working with gfortran 7.3.1. 回答1: This is not the kind of warning that one should turn

Disable check for override in gcc

老子叫甜甜 提交于 2019-12-11 02:47:17
问题 Is there a way to enforce gcc to ignore errors which result from C++11's override ? Explanation: I want to enable C++11 in a program. Unfortunately it misused some functions and macros from a library causing many marked override, but does not override errors. So I want to disable the error, just to check if there are more issues and then replace the errors step by step. I checked the -W options, but they handle warings only. This is a real error. 回答1: As a hack you can use -Doverride= on the

How to wrap functions with the `--wrap` option correctly?

倾然丶 夕夏残阳落幕 提交于 2019-12-10 19:20:46
问题 The man page of gcc 6.3 says: --wrap=symbol Use a wrapper function for symbol. Any undefined reference to symbol will be resolved to "__wrap_symbol". Any undefined reference to "__real_symbol" will be resolved to symbol. ... If you link other code with this file using --wrap malloc, then all calls to "malloc" will call the function "__wrap_malloc" instead. The call to "__real_malloc" in "__wrap_malloc" will call the real "malloc" function. So I created a simple example: #include <stdio.h> int

Undefined behavior or false positive

半城伤御伤魂 提交于 2019-12-10 18:24:20
问题 I've (essentially) come across the following in the wild x = x = 5; which apparently compiles cleanly under earlier version of gcc (generates a warning under gcc 4.5.1). As far as I can tell the warning is generated by -Wsequence-point. So my question is does this violate the wording in the standard about manipulating variables in between sequence points (i.e., it is undefined behavior per the spec) or is this a gcc false positive (i.e., it is defined behavior per the spec)? The wording on

Eigen with -O3 warning: argument 1 value ‘X’ exceeds maximum object size Y

≡放荡痞女 提交于 2019-12-10 17:14:50
问题 What happens When I try to add an Eigen::Vector3f into an std::vector following the tutorial on Eigen website like this: #include <Eigen/Core> #include <Eigen/StdVector> #include <iostream> template <class EigenT> using EigenStdVector = std::vector<EigenT, Eigen::aligned_allocator<EigenT>>; int main() { EigenStdVector<Eigen::Vector3f> vec; vec.emplace_back(1.0f, 1.0f, 1.0f); std::cerr << vec.back().transpose() << std::endl; return 0; } I get the following warning: In file included from /usr

Should the thread function return 0?

笑着哭i 提交于 2019-12-10 17:13:11
问题 I have this void function, with a pointer to my thread. when i go to compile, I get the warning: "control reaches end of non-void function". If I do void mythread (void *arg) and the function i will solve the warning that the compiler gives, but get a new warning, that says: TA.c:50:2: warning: passing argument 3 of ‘pthread_create’ from incompatible pointer type [enabled by default] So then, I put return 0; at the end of "mythread" function, and it compiles. But I'm not sure if this is the

TensorFlow doesnt build with debug mode

心已入冬 提交于 2019-12-10 15:13:34
问题 We are trying to build a TensorFlow test case with debug flag: bazel build -c dbg //tensorflow/python/kernel_tests:sparse_matmul_op_test However the build is failing with below error: /usr/include/features.h:330:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp] warning _FORTIFY_SOURCE requires compiling with optimization (-O) cc1: all warnings being treated as errors Target //tensorflow/python/kernel_tests:sparse_matmul_op_test failed to build We have

enforcing type safety when casting char* to bool in C++11

别说谁变了你拦得住时间么 提交于 2019-12-10 13:33:22
问题 Following code compiles fine without any warnings (with default options to g++). Is there a flag that we can use to ask g++ to emit warnings in such cases? void foo(bool v) { } void bar() { foo("test"); } 回答1: I like to try clang -Weverything and pick the warnings that pop out: void foo(bool) {} void bar() { foo("test"); } void baz() { foo(nullptr); } int main() {} main.cpp:5:7: warning: implicit conversion turns string literal into bool: 'const char [5]' to 'bool' [-Wstring-conversion] foo(

How to obtain warning for forgotten cast in arithmetic?

风流意气都作罢 提交于 2019-12-10 09:25:06
问题 Consider this situation: uint64_t add(uint32_t a, uint32_t b) { return a + b; // programmer neglected (uint64_t) a + b. } How do we get the C or C++ front-end of GCC (or of any other compiler) to warn about this situation: that an operation is being done in a narrow type that is immediately widened? I've read through the current GCC documentation, and tried various warnings like -Wconversion , but nothing. 回答1: I am not aware of a flag to GCC that will cause a warning. The Coverity static

Why doesn't gcc -Wformat warn about printf %d on an unsigned int?

前提是你 提交于 2019-12-10 02:51:58
问题 The following program has undefined behavior: #include <stdio.h> int main(void) { unsigned int x = -100; // This is fine, becomes UINT_MAX - 100 printf("%d\n", x); // This is undefined behavior. return 0; } C99 7.19.6.1p8 states %d expects an int argument. C99 7.19.6.1p9 states "If any argument is not the correct type for the corresponding conversion specification, the behavior is undefined ." However, gcc -Wformat (which is included with -Wall ) will not complain about the above program, why