c++/10541: Is NULL a valid pointer-type template argument?

bangerth@dealii.org bangerth@dealii.org
Tue Apr 29 17:25:00 GMT 2003


Old Synopsis: template <char * w_val > does not work
New Synopsis: Is NULL a valid pointer-type template argument?

State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Tue Apr 29 16:37:30 2003
State-Changed-Why:
    Your first case is invalid, since 0 is of type int,
    but a char* is required. The last one is also invalid,
    since the address of an object with external linkage
    is required, but you give the value of a member variable.
    
    Remains the question whether
    --------------------
    template <char *> class T {};
    T<static_cast<char *>(0)> t;
    --------------------------
    is legal. I tend to think that this is not so (but icc7
    disagrees with me), given 14.1.3:
    
    3 A non-type template-parameter shall have one of the following (option-
      ally cv-qualified) types:
    
    [...]
    --pointer to object, accepting an address constant  expression  desig-
        nating a named object with external linkage,
    
    The NULL pointer is certainly not the address of a named
    object, but I can see why it would be useful to allow
    this special case.
    
    I leave this last question to more seasoned language lawyers.
    
    W.
    
    
    but 

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10541



More information about the Gcc-bugs mailing list