- #1
m4r35n357
- 658
- 148
Yes I've already looked on SO! None of the answers contain the word "may". My story is that I am passing in references to global variables, modifying them, and returning them in array literals. I suppose it must complaining about the array literals (c99) rather than the variables themselves, but how should I re-write it ([EDIT] the code runs and gives the correct answer BTW)?
Here is the function:
and here is the error message:
Here is the function:
Code:
double *t_sin_cos (double *S, double *C, double *U, int k) {
assert((S != C) && (S != U) && (C != U));
assert(k >= 0);
if (k == 0) {
sincos(U[0], S, C);
return (double[2]) {S[0] / k, - C[0] / k};
} else {
S[k] = 0.0;
C[k] = 0.0;
for (int j = 0; j < k; j++) {
S[k] += (k - j) * U[k - j] * C[j];
C[k] += (k - j) * U[k - j] * S[j];
}
return (double[2]) {S[k] / k, - C[k] / k};
}
}
Code:
taylor-ode.c: In function ‘t_sin_cos’:
cc1: warning: function may return address of local variable [-Wreturn-local-addr]
taylor-ode.c:70:28: note: declared here
return (double[2]) {S[0] / k, - C[0] / k};
^
cc1: warning: function may return address of local variable [-Wreturn-local-addr]
taylor-ode.c:78:28: note: declared here
return (double[2]) {S[k] / k, - C[k] / k};
^
Last edited: