public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/29148]  New: can't subtract 'volatile char *' from 'const char *'
@ 2006-09-20 11:47 andrew dot stubbs at st dot com
  2006-09-20 12:58 ` [Bug c++/29148] " rguenth at gcc dot gnu dot org
  0 siblings, 1 reply; 3+ messages in thread
From: andrew dot stubbs at st dot com @ 2006-09-20 11:47 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1615 bytes --]

#include <stdio.h>

char str[] = "abc";

const char *a1 = str;
struct A { operator const char *() {return str;} } a2;

volatile char *b1 = str;
struct B { operator volatile char *() {return str;} } b2;

int
main()
{

  printf ("%p\n", a1);
  printf ("%p\n", b1);
  printf ("%p\n", (const char *)a2);
  printf ("%p\n", (volatile char *)b2);

  printf ("%d\n", a1 - b1);
  printf ("%d\n", (const char *)a2 - (volatile char *)b2);
  printf ("%d\n", a2 - b2);  // error reported here

  return 0;
}

gives:
t.cpp: In function ‘int main()’:
t.cpp:22: error: no match for ‘operator-’ in ‘a2 - b2’
t.cpp:22: note: candidates are: operator-(volatile char*, volatile char*)
<built-in>
t.cpp:22: note:                 operator-(const char*, const char*) <built-in>

However, lines 20 and 21 clearly do the same operation, but slightly
differently. These lines appear to be able to convert the types, presumably
according to clause 4.4 of the C++ standard, but the last example cannot. Yet
the error message shows that it has found the right conversion operators.

EDG 3.0 compiles this without any issues.

Note: the correct behaviour of this program is to print the same pointer four
times, and then print zero three times.


-- 
           Summary: can't subtract 'volatile char *' from 'const char *'
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: andrew dot stubbs at st dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29148


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/29148] can't subtract 'volatile char *' from 'const char *'
  2006-09-20 11:47 [Bug c++/29148] New: can't subtract 'volatile char *' from 'const char *' andrew dot stubbs at st dot com
@ 2006-09-20 12:58 ` rguenth at gcc dot gnu dot org
  0 siblings, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-09-20 12:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2006-09-20 12:58 -------
Confirmed.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |rejects-valid
   Last reconfirmed|0000-00-00 00:00:00         |2006-09-20 12:58:20
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29148


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/29148] can't subtract 'volatile char *' from 'const char *'
       [not found] <bug-29148-4@http.gcc.gnu.org/bugzilla/>
@ 2011-10-12 21:40 ` paolo.carlini at oracle dot com
  0 siblings, 0 replies; 3+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-12 21:40 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29148

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|gcc-bugs at gcc dot gnu.org |
         Resolution|                            |DUPLICATE
      Known to fail|                            |

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-12 21:37:54 UTC ---
Closing as duplicate.

*** This bug has been marked as a duplicate of bug 38174 ***


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-10-12 21:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-20 11:47 [Bug c++/29148] New: can't subtract 'volatile char *' from 'const char *' andrew dot stubbs at st dot com
2006-09-20 12:58 ` [Bug c++/29148] " rguenth at gcc dot gnu dot org
     [not found] <bug-29148-4@http.gcc.gnu.org/bugzilla/>
2011-10-12 21:40 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).