[sisyphus] GCC 3.3 vs GCC 3.4

Dmitry V. Levin =?iso-8859-1?q?ldv_=CE=C1_altlinux=2Eorg?=
Пн Апр 11 14:41:20 MSD 2005


Hi,

On Mon, Apr 11, 2005 at 12:04:13PM +0400, Epiphanov Sergei wrote:
> Есть программа test.cpp, приложенная в аттаче.
> 
> Стоят GCC 3.3 и GCC 3.4. Даю команды:
> 
> $ GCC_VERSION=3.3 g++ -o test test.cpp
> $ ./test
> Res1: 7
> Res2: 5
> Res3: 0
> Res4: 1
> $ GCC_VERSION=3.4 g++ -o test test.cpp
> test.cpp: In function `int main(int, char**)':
> test.cpp:30: error: no matching function for call to `Test::Test(Test)'
> test.cpp:7: note: candidates are: Test::Test(Test&)
> test.cpp:6:	                              Test::Test(int)
> $
> 
> Глюк в компиляторе 3.4? Программа - это выжимка работы класса QMap из Qt.

$ g++ --version |fgrep g++
i586-alt-linux-g++ (GCC) 3.4.3 20050314 (ALT Linux, build 3.4.3-alt6)
$ g++ -c test.cpp
test.cpp:14: error: `Test' does not name a type
test.cpp: In function `int ins(const int&, const Test&)':
test.cpp:18: error: `ff' undeclared (first use this function)
test.cpp:18: error: (Each undeclared identifier is reported only once for each function it appears in.)
test.cpp: In function `int main(int, char**)':
test.cpp:28: error: `ff' undeclared (first use this function)
test.cpp:29: error: no matching function for call to `Test::Test(Test)'
test.cpp:7: note: candidates are: Test::Test(Test&)
test.cpp:6: note:                 Test::Test(int)

1. Определение класса должно завершаться символом ";".
2. Согласно /usr/share/doc/gcc-3.4/NEWS.html,
"G++ is now much closer to full conformance to the ISO/ANSI C++ standard.
This means, among other things, that a lot of invalid constructs which
used to be accepted in previous versions will now be rejected.  It is
very likely that existing C++ code will need to be fixed."

В данном случае речь идёт о том, что конструктор "Test::Test(Test &t)"
следует заменить конструктором "Test::Test(const Test &t)".


-- 
ldv
----------- следующая часть -----------
Было удалено вложение не в текстовом формате...
Имя     : =?iso-8859-1?q?=CF=D4=D3=D5=D4=D3=D4=D7=D5=C5=D4?=
Тип     : application/pgp-signature
Размер  : 189 байтов
Описание: =?iso-8859-1?q?=CF=D4=D3=D5=D4=D3=D4=D7=D5=C5=D4?=
Url     : <http://lists.altlinux.org/pipermail/sisyphus/attachments/20050411/aa4f2eaa/attachment-0003.bin>


Подробная информация о списке рассылки Sisyphus