<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/98449>98449</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Gradient of an accumulation obtained by a for-loop
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          de-sholl
      </td>
    </tr>
</table>

<pre>
    The code
```

double f(double const* const x, std::size_t const n)
{
        double acc{};
        for (std::size_t i = 0; i < n; ++i)
                acc += x[i] * x[i];
        return acc;
}

int main()
{
        auto g = clad::gradient(f, "x[0:1]");

        std::vector<double> x = { 3, 4 },
                dx(x.size());
        g.execute(x.data(), x.size(), dx.data());

        std::cout << dx[0] << std::endl;
        return 0;
}
```

produces the following error:

> member reference base type 'double' is not a structure or union.

When I change the definition of `f` to

```
double f(double const* const x, std::size_t const n)
{
        double acc = x[0] * x[0];
        for (std::size_t i = 1; i < n; ++i)
                acc += x[i] * x[i];
        return acc;
}
```

then everything works fine. Can this problem be solved somehow?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VM2O6zYPfRp6Q0ygSE5sL7zIz82Hb1-gy0KW6FitLAWSnMn06Qs5npnkIri7FghiWqQPDw9JyRjN2RG1sNnD5ljIKQ0-tJre4uCtLTqvP9rfBkLlNQE7AtvBli2_--v8r_3UWcIeeL2YyruYgO_uBt6AHzAmDWIHYhfN3_RHWlwOeLNgVftP0GaBkUrl0-oI4tvX-4DA65_hDII4IgOxn80DumwC3wPfm-8krAHWSKVmjzjiDTZ7A5sjZrafL4_pAqUpuJnK12l1fCzfuISjNA54_bIYOSWP55mesnJhfQ5SG3IJeN1ndYDznJ2B2K0zA84z1jePBeur6iup5AOIw10qED_wNqeAao8iI5aYefLDY-H6Bry-rbJkC9unJM15RTdSU6I5TMskP8MO-PzZAfVzwK_IKj-l3JPcFn0vMyt-P_iKIqftC-XZC91fTeEleD0pipgGwt5b69-NOyOFkHXaPXETP3CksaOAgXoK5BRhJyNh-rgQAq8WVXmFJqLzCSXGFCaVpkDoA07OeLd6xPx9IIf_RzVId6aZg6beOJOMd-h7hC3rYcsw-Scmz5X8m5uEn-POHsed_TTuv9yu9X-7Xa-6nLLMdKXwkYbc3ncf_orYG0crPEiHaTARL8F3lkbsCKO3V9IY_UiDfwdxKnQrdCMaWVC7rjjb1vWmaoqhpU4ooWvdlUprXZMot_V2ozu9ZbKkritMyxkvWbVes4bxTbPqt6XQfVUyKtWmq3soGY3S2JW113Hlw7kwMU7UNnVZNoWVHdk437WcO3rH2ZkXfXMsQpu_eeumc4SSWRNT_EZJJllq_7fcGHmY5CzZNE5W3uerS9I40th9oMTehzfr_aWYgm2HlC4x95KfgJ_OJg1Tt1J-BH7KCZbH2yX4P0kl4KeZVgR-utO-tvyfAAAA___5t7vQ">