public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/8780: std::vector iterators not recognized as pointers by templates in certain cases
@ 2002-12-04 10:24 paolo
  0 siblings, 0 replies; 4+ messages in thread
From: paolo @ 2002-12-04 10:24 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, johnb, paolo

Synopsis: std::vector iterators not recognized as pointers by templates in certain cases

State-Changed-From-To: feedback->closed
State-Changed-By: paolo
State-Changed-When: Wed Dec  4 10:24:20 2002
State-Changed-Why:
    Ok, feedback not forthcoming, and some additional useful
    information provided by Joe. We can safely close it, now.

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


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

* Re: libstdc++/8780: std::vector iterators not recognized as pointers by templates in certain cases
@ 2002-12-04 10:26 Joe Buck
  0 siblings, 0 replies; 4+ messages in thread
From: Joe Buck @ 2002-12-04 10:26 UTC (permalink / raw)
  To: paolo; +Cc: gcc-prs

The following reply was made to PR libstdc++/8780; it has been noted by GNATS.

From: Joe Buck <jbuck@synopsys.com>
To: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, johnb@stl.sarov.ru,
   gcc-bugs@gcc.gnu.org, paolo@gcc.gnu.org
Cc:  
Subject: Re: libstdc++/8780: std::vector iterators not recognized as pointers
 by templates in certain cases
Date: Wed, 04 Dec 2002 10:21:03 -0800

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8780
 
 Thanks for the report, but this is not a bug.
 
 Any code that assumes that a vector<T>::iterator is a pointer is 
 non-portable
 and will break on many C++ implementations (including debug implementations,
 which use extra fields in the iterator to detect dereferencing of out of 
 range
 iterators).
 
 
 If you have code that makes such assumptions, then for cases where you know
 that the iterator is not pointing to vec.end(), the construct &*iter 
 will give
 a valid pointer to the data (and you may portably assume that the data are
 stored contiguously in the vector).  A portable one-past-the-end pointer is
 1+&vec.back() .
 
 


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

* Re: libstdc++/8780: std::vector iterators not recognized as pointers by templates in certain cases
@ 2002-12-02  5:31 paolo
  0 siblings, 0 replies; 4+ messages in thread
From: paolo @ 2002-12-02  5:31 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, johnb, nobody, paolo

Synopsis: std::vector iterators not recognized as pointers by templates in certain cases

Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-By: paolo
Responsible-Changed-When: Mon Dec  2 05:31:05 2002
Responsible-Changed-Why:
    Analyzed (with Gaby)
State-Changed-From-To: open->feedback
State-Changed-By: paolo
State-Changed-When: Mon Dec  2 05:31:05 2002
State-Changed-Why:
    This seems just a QoI issue. The wording of 24.1,(1,2) do
    *not* imply that an iterator *is* a pointer (it says that
    iterators are abstractions of pointers, that they support
    *i, and so on, this is different). Indeed, in some
    implementations (e.g., v2 bundled with 2.95.x) they are just
    pointers but this doesn't mean that the current
    implementation is non conforming. Do you agree?
    Thanks, Paolo.

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


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

* libstdc++/8780: std::vector iterators not recognized as pointers by templates in certain cases
@ 2002-12-02  1:06 johnb
  0 siblings, 0 replies; 4+ messages in thread
From: johnb @ 2002-12-02  1:06 UTC (permalink / raw)
  To: gcc-gnats


>Number:         8780
>Category:       libstdc++
>Synopsis:       std::vector iterators not recognized as pointers by templates in certain cases
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Dec 02 01:06:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Eugeny Belov
>Release:        g++ (GCC) 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
>Organization:
>Environment:
Red Hat Linux 8.0.
>Description:
  The attached testcase code uses STL to check whether the type given in the template specification of is_pointer_helper (in this case std::vector<int>::iterator) is a pointer type. (See also ISO\IEC 14882, 24.1.(1,2))
  So, trying to compile this testcase by g++ I get the error messages:
tr18877.cpp: In function `int main()':
tr18877.cpp:37: `sizeof' applied to incomplete type `
   STATIC_ASSERTION_FAILURE<false>'
tr18877.cpp:37: declaration does not declare anything
  The first error occure due the vector<int> iterator isn`t a pointer type, the second warning is legitimate.

>How-To-Repeat:
Try to compile the testcase with g++.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="veciter.cpp"
Content-Disposition: inline; filename="veciter.cpp"

#include <vector>
//#include <list>

template<int> struct static_assert_test{};

template <bool> struct STATIC_ASSERTION_FAILURE;
template <> struct STATIC_ASSERTION_FAILURE<true>{};

#define BOOST_STATIC_ASSERT( B ) static_assert_test<sizeof(STATIC_ASSERTION_FAILURE< ( B ) >)>

template <typename T> struct is_pointer_helper
{ static const bool value = false; };
template <typename T> struct is_pointer_helper<T*>
{ static const bool value = true; };
template <typename T> struct is_pointer_helper<T*const>
{ static const bool value = true; };
template <typename T> struct is_pointer_helper<T*volatile>
{ static const bool value = true; };
template <typename T> struct is_pointer_helper<T*const volatile>
{ static const bool value = true; };


int main(void)
{
	BOOST_STATIC_ASSERT(is_pointer_helper<std::vector<int>::iterator>::value);

	return(0);
}


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

end of thread, other threads:[~2002-12-04 18:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-04 10:24 libstdc++/8780: std::vector iterators not recognized as pointers by templates in certain cases paolo
  -- strict thread matches above, loose matches on Subject: below --
2002-12-04 10:26 Joe Buck
2002-12-02  5:31 paolo
2002-12-02  1:06 johnb

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).