<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.6266" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV>On Saturday, August 25, 2012 7:34 AM, Richard Smith wrote:</DIV>
<BLOCKQUOTE dir=ltr 
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style="FONT: 10pt arial"><STRONG></STRONG> </DIV>
  <DIV class=gmail_quote>
  <BLOCKQUOTE class=gmail_quote 
  style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Could 
    you give me some example code for your "nasty corner case", and I'll<BR>fix 
    my code.  Thanks.<BR></BLOCKQUOTE>
  <DIV><BR></DIV>
  <DIV>extern const int n;</DIV>
  <DIV>constexpr int get() { return n; }</DIV>
  <DIV>constexpr int n = get() + 1;</DIV>
  <DIV>constexpr int m = get();</DIV>
  <DIV>static_assert(m == n, "");</DIV>
  <DIV><FONT face=Arial size=2></FONT> </DIV></DIV></BLOCKQUOTE>
<DIV dir=ltr><FONT face=Arial size=2>Wow, that is nasty and my first thought 
was: is that even legal?</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2>This is the output from gcc 
4.7.1:</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2>~/testcase$ g++ -std=c++11 horrible.cpp 
<BR>horrible.cpp: In function ‘constexpr int get()’:<BR>horrible.cpp:2:33: 
error: the value of ‘n’ is not usable in a constant 
expression<BR>horrible.cpp:1:18: note: ‘n’ was not initialized with a constant 
expression<BR>horrible.cpp: At global scope:<BR>horrible.cpp:3:15: error: 
redeclaration ‘n’ differs in ‘constexpr’<BR>horrible.cpp:1:18: error: from 
previous declaration ‘n’<BR>horrible.cpp:4:23: error: ‘constexpr int get()’ 
called in a constant expression<BR></FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2>What does the standard say? (I haven't got 
a copy myself.)</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2>Cheers</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2>Andy</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2> </DIV></FONT></BODY></HTML>