g++ compile error

The forum to report every bug you find or tell us what you'd like to find in UVa OJ

Moderator: Board moderators

Locked
tryit1
Experienced poster
Posts: 119
Joined: Sun Aug 24, 2008 9:09 pm

g++ compile error

Post by tryit1 »

hi,
i think the judge uses older version of g++.

On judge i get error see bottom for error.

Code: Select all

#include<cstdio>
#include<tr1/unordered_map>
#include<algorithm>
using namespace std;
using namespace tr1;
typedef unsigned long long ull;
unordered_map<ull,ull> m;

int main(){	
	return 0;
}

junk@edubuntu:~$ g++ fooe.cpp             <<<<<<<=============== SEE THIS =========
junk@edubuntu:~$ g++ -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-targets=all --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7)
junk@edubuntu:~$ 

=================JUDGE ERROR===========================

/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/tr1/hashtable: In instantiation of 'Internal::hash_code_base, Internal::extract1st >, std::equal_to, std::tr1::hash, Internal::mod_range_hashing, Internal::default_ranged_hash, false>':
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/tr1/hashtable:1014: instantiated from 'std::tr1::hashtable, std::allocator >, Internal::extract1st >, std::equal_to, std::tr1::hash, Internal::mod_range_hashing, Internal::default_ranged_hash, Internal::prime_rehash_policy, false, false, true>'
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/tr1/unordered_map:65: instantiated from 'std::tr1::unordered_map, std::equal_to, std::allocator >, false>'
code.cpp:8: instantiated from here
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/tr1/hashtable:863: error: 'Internal::hash_code_base::m_h1' has incomplete type
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/tr1/functional:1103: error: declaration of 'struct std::tr1::hash'
code.cpp: In constructor 'std::tr1::unordered_map::unordered_map(typename std::tr1::hashtable, Alloc, Internal::extract1st >, Pred, Hash, Internal::mod_range_hashing, Internal::default_ranged_hash, Internal::prime_rehash_policy, cache_hash_code, false, true>::size_type, const typename std::tr1::hashtable, Alloc, Internal::extract1st >, Pred, Hash, Internal::mod_range_hashing, Internal::default_ranged_hash, Internal::prime_rehash_policy, cache_hash_code, false, true>::hasher&, const typename std::tr1::hashtable, Alloc, Internal::extract1st >, Pred, Hash, Internal::mod_range_hashing, Internal::default_ranged_hash, Internal::prime_rehash_policy, cache_hash_code, false, true>::key_equal&, const typename std::tr1::hashtable, Alloc, Internal::extract1st >, Pred, Hash, Internal::mod_range_hashing, Internal::default_ranged_hash, Internal::prime_rehash_policy, cache_hash_code, false, true>::allocator_type&) [with Key = long long unsigned int, T = long long unsigned int, Hash = std::tr1::hash, Pred = std::equal_to, Alloc = std::allocator >, bool cache_hash_code = false]':
code.cpp:8: error: invalid use of undefined type 'struct std::tr1::hash'
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/tr1/functional:1103: error: declaration of 'struct std::tr1::hash'
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/tr1/hashtable: In constructor 'Internal::hash_code_base::hash_code_base(const ExtractKey&, const Equal&, const H1&, const H2&, const Internal::default_ranged_hash&) [with Key = long long unsigned int, Value = std::pair, ExtractKey = Internal::extract1st >, Equal = std::equal_to, H1 = std::tr1::hash, H2 = Internal::mod_range_hashing]':
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/tr1/hashtable:1392: instantiated from 'std::tr1::hashtable::hashtable(typename Allocator::size_type, const H1&, const H2&, const H&, const Eq&, const Ex&, const Allocator&) [with Key = long long unsigned int, Value = std::pair, Allocator = std::allocator >, ExtractKey = Internal::extract1st >, Equal = std::equal_to, H1 = std::tr1::hash, H2 = Internal::mod_range_hashing, H = Internal::default_ranged_hash, RehashPolicy = Internal::prime_rehash_policy, bool cache_hash_code = false, bool constant_iterators = false, bool unique_keys = true]'
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/tr1/unordered_map:88: instantiated from 'std::tr1::unordered_map::unordered_map(typename std::tr1::hashtable, Alloc, Internal::extract1st >, Pred, Hash, Internal::mod_range_hashing, Internal::default_ranged_hash, Internal::prime_rehash_policy, cache_hash_code, false, true>::size_type, const typename std::tr1::hashtable, Alloc, Internal::extract1st >, Pred, Hash, Internal::mod_range_hashing, Internal::default_ranged_hash, Internal::prime_rehash_policy, cache_hash_code, false, true>::hasher&, const typename std::tr1::hashtable, Alloc, Internal::extract1st >, Pred, Hash, Internal::mod_range_hashing, Internal::default_ranged_hash, Internal::prime_rehash_policy, cache_hash_code, false, true>::key_equal&, const typename std::tr1::hashtable, Alloc, Internal::extract1st >, Pred, Hash, Internal::mod_range_hashing, Internal::default_ranged_hash, Internal::prime_rehash_policy, cache_hash_code, false, true>::allocator_type&) [with Key = long long unsigned int, T = long long unsigned int, Hash = std::tr1::hash, Pred = std::equal_to, Alloc = std::allocator >, bool cache_hash_code = false]'
code.cpp:8: instantiated from here
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/tr1/hashtable:823: error: using invalid field 'Internal::h

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Re: g++ compile error

Post by mf »

What's exactly the bug here?
TR1 is not yet part of standard C++, it's only a proposal, so things like an incomplete implementation can happen. We have to wait until C++0x arrives, and g++ announces its support.

vahid sanei
Learning poster
Posts: 84
Joined: Fri Jan 09, 2009 4:37 pm
Location: IRAN

What is the Presentation Error ??

Post by vahid sanei »

i get presentation error
i checked my e-mail and there have been write , i solved the problem successfully , but my bug is format of output,
what should i do?

here is my code ,that get PE

Code: Select all

Removed After AC
thanks in advance
Last edited by vahid sanei on Fri Jan 16, 2009 9:10 pm, edited 1 time in total.
Impossible says I`m possible

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Re: What is the Presentation Error ??

Post by helloneo »

vahid sanei wrote:i get presentation error
i checked my e-mail and there have been write , i solved the problem successfully , but my bug is format of output,
what should i do?

here is my code ,that get PE

thanks in advance
Your code prints an extra space at the end of some of lines..
Change all ' ' to 'B' in your code, then you'll see it clearly

Remove your code here

http://acm.uva.es/board/viewtopic.php?f ... &start=150

vahid sanei
Learning poster
Posts: 84
Joined: Fri Jan 09, 2009 4:37 pm
Location: IRAN

--

Post by vahid sanei »

tanx helloneo :D
Impossible says I`m possible

alirezanoori
New poster
Posts: 26
Joined: Fri Jan 02, 2009 12:41 am

Re: g++ compile error

Post by alirezanoori »

Hi guys.
Well, I have a problem.
In many of my codes when I use the sort function on a 'user defined' data structure (struct) I get a compilation error from judge!! Why is this happening? I wrote many codes with this feature and I cannot write them again.
here is a part of the code that I get Compilation Error.

Code: Select all

    for(i = 0; i < size; i++)
        sort(ResLines[i].begin(), ResLines[i].end(), pointSortHelper);
    sort(ResLines.begin(), ResLines.end(), lineSortHelper);
and here is the error:

Code: Select all

/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/bits/stl_algo.h: In function 'const _Tp& std::__median(const _Tp&, const _Tp&, const _Tp&, _Compare) [with _Tp = std::pair, _Compare = bool (*)(point&, point&)]':
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/bits/stl_algo.h:2679:   instantiated from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator*, std::vector, std::allocator > > >, _Size = int, _Compare = bool (*)(point&, point&)]'
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/bits/stl_algo.h:2749:   instantiated from 'void std::sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator*, std::vector, std::allocator > > >, _Compare = bool (*)(point&, point&)]'
code.cpp:126:   instantiated from here
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/bits/stl_algo.h:125: error: invalid initialization of reference of type 'point&' from expression of type 'const std::pair'
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/bits/stl_algo.h:126: error: invalid initialization of reference of type 'point&' from expression of type 'const std::pair'
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/bits/stl_algo.h:128: error: invalid initialization of reference of type 'point&' from expression of type 'const std::pair'
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/bits/stl_algo.h:132: error: invalid initialization of reference of type 'point&' from expression of type 'const std::pair'
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/bits/stl_algo.h:134: error: invalid initialization of reference of type 'point&' from expression of type 'const std::pair'
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/bits/stl_algo.h: In function 'const _Tp& std::__median(const _Tp&, const _Tp&, const _Tp&, _Compare) [with _Tp = std::vector, std::allocator > >, _Compare = bool (*)(line&, line&)]':
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/bits/stl_algo.h:2679:   instantiated from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator, std::allocator > >*, std::vector, std::allocator > >, std::allocator, std::allocator > > > > >, _Size = int, _Compare = bool (*)(line&, line&)]'
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/bits/stl_algo.h:2749:   instantiated from 'void std::sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator, std::allocator > >*, std::vector, std::allocator > >, std::allocator, std::allocator > > > > >, _Compare = bool (*)(line&, line&)]'
code.cpp:127:   instantiated from here
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/bits/stl_algo.h:125: error: invalid initialization of reference of type 'line&' from expression of type 'const std::vector, std::allocator > >'
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/bits/stl_algo.h:126: error: invalid initialization of reference of type 'line&' from expression of type 'const std::vector, std::allocator > >'
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/bits/stl_algo.h:128: error: invalid initialization of reference of type 'line&' from expression of type 'const std::vector, std::allocator > >'
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/bits/stl_algo.h:132: error: invalid initialization of reference of type 'line&' from expression of type 'const std::vector, std::allocator > >'
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/bits/stl_algo.h:134: error: invalid initialization of reference o

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Re: g++ compile error

Post by mf »

That part of code is OK by itself.

Post definition of ResLines, and code of pointSortHelper and lineSortHelper here. Or better yet, your complete code. As far as I can tell from gcc errors, you have some type conversions errors there.

alirezanoori
New poster
Posts: 26
Joined: Fri Jan 02, 2009 12:41 am

Re: g++ compile error

Post by alirezanoori »

Well, ok.
Here's my code.

Code: Select all

Code Removed.
Last edited by alirezanoori on Wed Mar 04, 2009 7:34 pm, edited 1 time in total.

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Re: g++ compile error

Post by mf »

Use const references in the arguments of comparison functions.

i.e. pointSortHelper(const point &a, const point &b) instead of pointSortHelper(point &a, point &b).

alirezanoori
New poster
Posts: 26
Joined: Fri Jan 02, 2009 12:41 am

Re: g++ compile error

Post by alirezanoori »

Thanks alot.
Now I get my WA!!! :))

Locked

Return to “Bugs and suggestions”