From 6551841658674915794 X-Google-Thread: f78e5,15eca2a4a64f411f,start X-Google-Attributes: gidf78e5,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.speakeasy.net!news.speakeasy.net.POSTED!not-for-mail NNTP-Posting-Date: Sat, 25 Feb 2006 10:30:08 -0600 Return-Path: X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov) Delivered-To: std-c++@ucar.edu From: "Krzysztof �elechowski" Newsgroups: comp.std.c++ Subject: 4.4: Amendment: pointers to similar arrays Organization: ATCOM ISP http://www.atcom.pl Message-ID: X-Complaints-To: news@atcom.pl Keywords: convert pointer array constant X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2670 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 X-Virus-Scanned: amavisd-new at ucar.edu X-Virus-Scanned: amavisd-new at cs.mu.OZ.AU Approved: Fergus Henderson , moderator of comp.std.c++ X-Virus-Scanned: amavisd-new at cs.mu.OZ.AU X-Amavis-Alert: BAD HEADER Non-encoded 8-bit data (char AF hex) in message header 'From': From: "Krzysztof \257elechowski" 0 such that: T1 is cv1,0 pointer to cv1,1 pointer to ... cv1,n-1 pointer to cv1,n T and T2 is cv2,0 pointer to cv2,1 pointer to ... cv2,n-1 pointer to cv2,n T where each cvi, j is const, volatile, const volatile, or nothing. The n-tuple of cv-qualifiers after the first in a pointer type, e.g., cv1,1, cv1,2, ..., cv1,n in the pointer type T1, is called the cv-qualification signature of the pointer type. An expression of type T1 can be converted to type T2 if and only if the following conditions are satisfied: - the pointer types are similar. - for every j > 0, if const is in cv1, j then const is in cv2, j, and similarly for volatile. - if the cv1, j and cv2, j are different, then const is in every cv2,k for 0 < k < j. PROBLEM STATEMENT 4.4. handles conversions of pointers to pointers but it does not support converting pointers to arrays. The following example is ill-formed: int const *const (*foo(int *p_f[][02]))[02]{ return p_f; } In plain English: It is illegal to convert a pointer to an array of pointers to a pointer to a constant array of constant pointers. A real-world example: void printc(int const *const p_f[][02]); void print(int *p_f[][02]) { return printc(p_f); } // ill-formed They are ill-formed because the types of int const *[02] and int *[02] are different. It should not be ill-formed because if it were allowed it would not cause any compromise. PROPOSED RESOLUTION Add recurrence over arrays to clause 4.4, as follows: A conversion can add cv-qualifiers at levels other than the first in multi-level pointers, subject to the following rules:56) Two pointer types T1 and T2 are similar if there EXIST TYPES T3 AND T4 and integer n > 0 such that: T3 IS IDENTICAL TO T4 OR BOTH ARE ARRAYS OF SIMILAR POINTERS T1 is cv1,0 pointer to cv1,1 pointer to ... cv1,n-1 pointer to cv1,n T3 and T2 is cv2,0 pointer to cv2,1 pointer to ... cv2,n-1 pointer to cv2,n T4 where each cvi, j is const, volatile, const volatile, or nothing. The n-tuple of cv-qualifiers after the first in a pointer type, e.g., cv1,1, cv1,2, ..., cv1,n in the pointer type T1, is called the cv-qualification signature of the pointer type. An expression of type T1 can be converted to type T2 if and only if the following conditions are satisfied: - the pointer types are similar. - for every j > 0, if const is in cv1, j then const is in cv2, j, and similarly for volatile. - if the cv1, j and cv2, j are different, then const is in every cv2,k for 0 < k < j. - T3 IS IDENTICAL TO T4 OR THE POINTERS CONTAINED IN T3 CAN BE CONVERTED TO THE POINTERS CONTAINED IN T4 Please consider this amendment for the next edition of the Standard. Christopher --- [ comp.std.c++ is moderated. To submit articles, try just posting with ] [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ] [ --- Please see the FAQ before posting. --- ] [ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]