Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #5329
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!news.glorb.com!news-out.readnews.com!transit3.readnews.com!panix!not-for-mail |
|---|---|
| From | Ruben Safir <ruben@mrbrklyn.com> |
| Newsgroups | comp.lang.c++ |
| Subject | Re: gcc bug? |
| Date | Sun, 22 May 2011 11:35:03 +0000 (UTC) |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Lines | 90 |
| Message-ID | <irasd7$dno$1@reader1.panix.com> (permalink) |
| References | <ir9p34$odp$2@reader1.panix.com> <ir9snt$v6l$1@news.ett.com.ua> <slrnithdji.gtj.grahn+nntp@frailea.sa.invalid> |
| NNTP-Posting-Host | www2.mrbrklyn.com |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | reader1.panix.com 1306064103 14072 96.57.23.82 (22 May 2011 11:35:03 GMT) |
| X-Complaints-To | abuse@panix.com |
| NNTP-Posting-Date | Sun, 22 May 2011 11:35:03 +0000 (UTC) |
| X-Blackjet | Blackjet is a Yankee Fan |
| X-DRMisTHEFT | Use GNU Linux today |
| X-From | A Dark Cloud |
| X-LOCATION | Brooklyn NY - Forget abou' it! |
| X-NYLXS | Really - yah think computers are supposed to be broken? |
| User-Agent | Pan/0.133 (House of Butterflies) |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.c++:5329 |
Show key headers only | View raw
On Sun, 22 May 2011 07:08:35 +0000, Jorgen Grahn wrote:
> On Sun, 2011-05-22, Balog Pal wrote:
>> "Ruben Safir" <ruben@mrbrklyn.com>
>>> I've been working with gcc 4.6 with C++ doing some templates exercises
>>>
>>> I seem to have some unexplained behavior which might be a bug, or
>>> maybe I'm ignorant.
>>
>> maybe. first run your code in valgrind and look if it points out the
>> corruption.
>
> I get "75060 errors from 34 contexts" when I run the "del2" test, and
> they start appearing long before the crash. Most seem to be about
> accessing freed memory. I see no reason to suspect a compiler bug. (I
> used gcc 4.4; there is no use of experimental C++0x features in the
> code.)
>
> /Jorgen
ruben@www2:~/cplus/link_list_template_mysql> g++ -Wall -ggdb test_del2.cpp -o test_del2
ruben@www2:~/cplus/link_list_template_mysql>
compiles cleanly
I'm seeing a behavior I never saw before, though in the template
I have this class method in the template
template < class T >
void List<T>::find_value(T val)
{
cursor() = front();
while(cursor() != endd()){
if (*(cursor()->value()) == val)
return;
else{
cursor(cursor()->next());
}
}
if(*(endd()->value()) == val)
return;
else{
cursor() = 0; //park the cursor when nothing is found
}
}
I'm calling it from this snippit of code
template<typename T>
float mean_list(chainlist::List< chainlist::List<stats::Distribution<T> >* > * tallies, T search_val){
if(tallies->endd() == 0){
std::cout << "Empty List" << std::endl;
return 0.0;
}
int sum = 0;
chainlist::List<stats::Distribution<T> > * dump;
tallies->cursor() = tallies->front();
while(tallies->cursor() != tallies->endd() ){
//tallies->cursor()->value()->find_value(search_val);
dump = *(tallies->cursor()->value());
dump->find_value(search_val);
sum += dump->cursor()->value()->population();
}
dump = *(tallies->cursor()->value());
dump->find_value(search_val);
sum += dump->cursor()->value()->population();
return sum/(tallies->size());
}
that makes dump according to gdb a type of
(gdb) ptype dump
type = class chainlist::List<stats::Distribution<int> >
with a public member function
void find_value(stats::Distribution<int>);
all of which I expected. What I don't expect is that when I call from main
std::cout << "The standard mean for picking 7 is ==> " << stats::mean_list(tallies, 7 );
then T has to be defined as a integer, and the param 7 is being promoted and calling the Distribution object constructor.
.
Ruben
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
gcc bug? Ruben Safir <ruben@mrbrklyn.com> - 2011-05-22 01:32 +0000
Re: gcc bug? "Balog Pal" <pasa@lib.hu> - 2011-05-22 04:34 +0200
Re: gcc bug? Ruben Safir <ruben@mrbrklyn.com> - 2011-05-22 04:13 +0000
Re: gcc bug? Ian Collins <ian-news@hotmail.com> - 2011-05-22 16:16 +1200
Re: gcc bug? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-05-22 07:08 +0000
Re: gcc bug? Ruben Safir <ruben@mrbrklyn.com> - 2011-05-22 11:35 +0000
Re: gcc bug? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-05-22 13:00 +0000
Re: gcc bug? Ruben Safir <ruben@mrbrklyn.com> - 2011-05-22 14:27 +0000
csiph-web