title: Is it safe to access non-const object through const lvalue?
body: <p>The <code>6.5(p7)</code> states this:</p>
  
  <blockquote>
    <p>An object shall have its stored value accessed only by an lvalue
    expression that has one of the following types:88)</p>
    
    <p>— a type compatible the effective type of the object,</p>
    
    <p>— a qualified version of a type compatible with the effective type of the object,</p>
    
    <p>— a type that is the
    signed or unsigned type corresponding to the effective type of the
    object,</p>
    
    <p>— a type that is the signed or unsigned type corresponding to
    a qualified version of the effective type of the object,</p>
  </blockquote>
  
  <p>Taking a look at <code>6.7.3(p10)</code>:</p>
  
  <blockquote>
    <p>For two qualified types to be compatible, both shall have the
    identically qualified version of a compatible type;</p>
  </blockquote>
  
  <p>So <code>double</code> and <code>const double</code> are not compatible because their type qualifiers are not the same.</p>
  
  <p>Now I assumed that <strong>signed or unsigned type</strong> mean <strong>signed or unsigned integer type</strong> as defined it <code>6.2.5(p4)</code> and <code>6.2.5(p6)</code> correspondingly since <code>6.2.5</code> does not define <strong>signed type</strong> by itself.</p>
  
  <p>Now consider the following code:</p>
  
  <pre><code>void print_double(const double d){
      printf("d = %lf\n", d);
  }
  
  int main(int args, const char *argv[]){
      double d = 10.2;
      print_double(d);
  }
  </code></pre>
  
  <p>Now I try to apply <code>6.5 (p7)</code>:</p>
  
  <p>I. <code>a type compatible the effective type of the object</code></p>
  
  <p>No, <code>const double</code> and <code>double</code> are not compatible.</p>
  
  <p>II. <code>a qualified version of a type compatible with the effective type of the object</code></p>
  
  <p>No, qualified version of <code>const double</code> will make it even more qualified then <code>const double</code></p>
  
  <p>III/IV.</p>
  
  <p>No, <code>double</code> is not a signed or unsigned integer type.</p>
  
  <p>This judgement seems faulty because it should be ok to access non-const object via const-qualified lvalue. But I cannot derive that from <code>6.5(p7)</code>.</p>