Summary: | Wconversion does not handle complex type conversions | ||
---|---|---|---|
Product: | gcc | Reporter: | Alexander <bratsinot> |
Component: | c | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED DUPLICATE | ||
Severity: | enhancement | CC: | manu |
Priority: | P3 | Keywords: | diagnostic |
Version: | 4.6.2 | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2011-11-04 00:00:00 | |
Attachments: | NULL |
Description
Alexander
2011-11-04 14:38:12 UTC
Please provide a *self-contained*, minimal testcase. Thanks, Created attachment 25714 [details]
NULL
I right now noticed that abs() just return real part of complex number.
#include <complex.h> extern int abs(int); int foo(void) { complex double Z = 0.1 + 0.2I; return abs(Z); } GCC says nothing with -Wall -Wextra -Wconversion, because c-common.c:conversion_warnings() does not handle complex variables. Clang: test.c:6:14: warning: implicit conversion discards imaginary component: '_Complex double' to 'int' [-Wconversion] return abs(Z); ~~~ ^ 1 warning generated. (In reply to comment #3) > #include <complex.h> > > extern int abs(int); > int foo(void) { > complex double Z = 0.1 + 0.2I; > return abs(Z); > } > > GCC says nothing with -Wall -Wextra -Wconversion, because > c-common.c:conversion_warnings() does not handle complex variables. > > Clang: > > test.c:6:14: warning: implicit conversion discards imaginary component: > '_Complex double' to 'int' [-Wconversion] > return abs(Z); > ~~~ ^ > 1 warning generated. I noticed. So what? Why was this done? (In reply to comment #4) > > I noticed. So what? Why was this done? It is just not implemented yet. Someone needs to want it enough to implement it. (In reply to comment #5) > (In reply to comment #4) > > > > I noticed. So what? Why was this done? > > It is just not implemented yet. Someone needs to want it enough to implement > it. May be people just not see that thing, like me(I noticed this only after a couple of hours). |