user4255: I'm unsure how this will be handled by the Arduino compiler. If anyone can explain what and why, I'd appreciate it. This is obviously very simplified, but it does contain the actual issue.
At the module level I have this union. I understand that this is strictly speaking not correct C++, but it does work for me, at least when used directly and not passed as a argument to a function.
  union _TAT {          // access as bytes or uint32
    uint32_t wide = 0;
    uint8_t bytes[4];
  };

  _TAT oneTAT;        // a variable of _TAT

Suppose I also have a function that works on these:
  void fix_Term(_TAT atat) {
    atat.wide = 0;
    atat.bytes[3] = 17;
  }

...and I invoke it with:
  fix_Term(oneTAT);

As I understand it, passing AnArray[] is equivalent to passing *AnArray, so the function might/should see atat.bytes[3] as a pointer to that byte of the variable. But what about atat.wide? I haven't explicitly passed oneTAT by reference, so...?
What might actually happen here? It does compile without complaint but I can't test it because the hardware it depends on isn't available yet. Besides, even if it works, I'd like to know why.
And of course, if it's just wrong, how do I best accomplish passing and modifying a variable like this?

user70044: Yes passing AnArray[] is equivalent to passing *AnArray. But declaring uint8_t *anarray1 is not equivalent to declaring uint8_t anarray2[4] in a struct/class/union definition. The former includes a pointer to a byte in the struct, the later actually includes 4 bytes in the struct. So in the later case, anarray2 already points to data, and using variable.anarray2[0] correctly gets you the value in the structure, while calling variable.anarray1[0] would result in undefined behavior, because the pointer just points anywhere.
So your code is compiling and executing without error, but since you're passing the union by value, the effect of your fix_term function is discarded, much like if you had passed in an ordinary value type instead (such as int).

user37622: It is confusing in C and C++ that arrays are passed as pointers but an instance of class, struct or union is always passed by value (so as a copy) including the arrays which are part of the memory space of the structure as in the case of your union.
If you want to pass by reference, declare the function's parameter as a reference 'type'. For example void fix_Term(_TAT& atat) {.

4255: <p>I'm unsure how this will be handled by the Arduino compiler. If anyone can explain what and why, I'd appreciate it. This is obviously very simplified, but it does contain the actual issue.</p>
<p>At the module level I have this <code>union</code>. I understand that this is strictly speaking not correct C++, but it does work for me, at least when used directly and not passed as a argument to a function.</p>
<pre><code>  union _TAT {          // access as bytes or uint32
    uint32_t wide = 0;
    uint8_t bytes[4];
  };

  _TAT oneTAT;        // a variable of _TAT
</code></pre>
<p>Suppose I also have a function that works on these:</p>
<pre><code>  void fix_Term(_TAT atat) {
    atat.wide = 0;
    atat.bytes[3] = 17;
  }
</code></pre>
<p>...and I invoke it with:</p>
<pre><code>  fix_Term(oneTAT);
</code></pre>
<p>As I understand it, passing <code>AnArray[]</code> is equivalent to passing <code>*AnArray</code>, so the function might/should see <code>atat.bytes[3]</code> as a pointer to that byte of the variable. But what about <code>atat.wide</code>? I haven't explicitly passed <code>oneTAT</code> by reference, so...?</p>
<p>What might actually happen here? It does compile without complaint but I can't test it because the hardware it depends on isn't available yet. Besides, even if it works, I'd like to know why.</p>
<p>And of course, if it's just wrong, how do I best accomplish passing and modifying a variable like this?</p>
 70044: <p>Yes passing <code>AnArray[]</code> is equivalent to passing <code>*AnArray</code>. <strong>But</strong> declaring <code>uint8_t *anarray1</code> is <em>not</em> equivalent to declaring <code>uint8_t anarray2[4]</code> in a struct/class/union definition. The former includes a pointer to a byte in the struct, the later actually includes 4 bytes in the struct. So in the later case, <code>anarray2</code> already points to data, and using <code>variable.anarray2[0]</code> correctly gets you the value in the structure, while calling <code>variable.anarray1[0]</code> would result in undefined behavior, because the pointer just points anywhere.</p>
<p>So your code is compiling and executing without error, but since you're passing the union by value, the effect of your <code>fix_term</code> function is discarded, much like if you had passed in an ordinary value type instead (such as int).</p>
 37622: <p>It is confusing in C and C++ that arrays are passed as pointers but an instance of class, struct or union is always passed by value (so as a copy) including the arrays which are part of the memory space of the structure as in the case of your union.</p>
<p>If you want to pass by reference, declare the function's parameter as a reference 'type'. For example <code>void fix_Term(_TAT&amp; atat) {</code>.</p>
