### Compiler Warning of an Error in istdops.h

#### Effect

You get a compiler warning indicating a problem in istdops.h (Note: the errors you encounter may not be exactly the same as the following):

The message text for OS/2 is:

    j:\...\ibmclass\istdops.h(166:1) : warning EDC3285:
      The address of a local variable or compiler temporary is being used
      in a return expression.
    j:\...\ibmclass\istdops.h(160:1) : informational EDC3207:
      The previous message applies to the definition of template
      "IStdKeyOps<Word,int>::key(const Word&) const".

The message text for AIX is:

    "/usr/lpp/xlC/include/istdops.h", line 166.1: 1540-151:
      (I) auto compiler temporary of type "int" has been generated.
    "/usr/lpp/xlC/include/istdops.h", line 160.1: 1540-207:
      (I) The previous message applies to the definition of template
      "IStdKeyOps<Word,int>::key(const Word&) const".

The message text for Solaris is:

    "/.../.../include/istdops.h", line 166.1: 1540-151:
      (I) auto compiler temporary of type "int" has been generated.
    "/.../.../include/istdops.h", line 160.1: 1540-207:
      (I) The previous message applies to the definition of template
      "IStdKeyOps<Word,int>::key(const Word&) const".

#### Reason

Compiler error messages indicating a problem in istdops.h are related to the element and key-type functions that you must define for your elements. These functions depend on the collection and implementation variant you are using.

Your global-name-space function key returns the key by value instead of by reference. A temporary variable is created for the key within the operator-class function key. The operator class function key returns the key by reference. Returning a reference to a temporary variable causes unpredictable results.

The key function must return a reference and must also take a reference argument. If the key function calls other functions to access the key, it must call those functions with a reference to the object as an argument, and those functions must return a reference to the key.

#### Solution

Verify that the global name-space function key correctly returns a key const& instead of key.

Introduction to the Collection Classes
Overall Implementation Structure
Element Functions and Key-Type Functions

Implementing Element- and Key-Type Functionality
Defining Member Functions of the Element Object Type
Defining Separate Global Functions
Using or Defining an Element Operation Class
Memory Management with Element Operation Classes
Possible Implementation Paths
Choosing One of the Provided Implementation Variants
Instantiating the Collection Classes
Unexpected Results when Adding an Element to a Unique Key Collection