Comeau всегда прав!...?

Автор: Григорий Зубанков
Опубликовано: 08.12.2006
Версия текста: 1.0

Код, который я пишу на работе, должен собираться сразу несколькими компиляторами. Само собой иногда возникают разногласия в их трактовках стандарта языка. Обычно, при неоднозначном результате, я считаю правым gcc, однако, в особо щекотливых ситуациях, проверяю код on-line вариантом Comeau (http://www.comeaucomputing.com/tryitout). Лишь затем «курю» стандарт, уточняя оставшиеся непонятными моменты. Comeau всегда дает мне 90% понимания сутации.

Камнем преткновения стал небольшой фрагмент кода, после которого я перестал так безоговорочно доверять Comeu.

Приведу свою переписку с отделом техподдержки Comeau:

From: Grigory Zubankov <Grigory.Zubankov@>)
To: support@comeaucomputing.com
Subject: comeau error
-------------------------------------------
Hello, 
This sample does not contain indicated error:

[Example:--- 

namespace bar
{
  struct D;
}

namespace foo 
{
  struct A {}; 
  void test(bar::D&) {} 
} 

namespace bar 
{ 
  template <class T> 
  struct B {}; 

  struct D : public B<foo::A> 
  { 
    void func() 
    { 
      test(D()); // must be Ok; comeau error: identifier "test" is undefined 
    } 
  }; 
} 

---end example] 

Reason (INTERNATIONAL STANDARD ISO/IEC 14882:2003) is:

3.4.2/2 Argument-dependent name lookup 
... 
For each argument type T in the function call, there is a set of zero or more associated namespaces and a set 
of zero or more associated classes to be considered. The sets of namespaces and classes is determined 
entirely by the types of the function arguments (and the namespace of any template template argument). 
Typedef names and using-declarations used to specify the types do not contribute to this set. The sets of 
namespaces and classes are determined in the following way: 

-- If T is a template-id, its associated namespaces and classes are the namespace in which the template is 
defined; for member templates, the member template’s class; the namespaces and classes associated 
with the types of the template arguments provided for template type parameters (excluding template 
template parameters) ; the namespaces in which any template template arguments are defined; and the 
classes in which any member templates used as template template arguments are defined. 
... 

-------
Grigory Zubankov

Первый ответ:

From: support@comeaucomputing.com
To: Grigory Zubankov <Grigory.Zubankov@>)
Subject: comeau error
-----------------------------------------
Thanks for the report.  Now that you mentioned in 3.4.2/2 is rather 
confusing.  We'll be looking into it and getting back to you shortly.

-------
Comeau C/C++ 4.3.3:  Now in our 20th year!
Comeau C/C++ ONLINE ==>  http://www.comeaucomputing.com/tryitout
World Class Compilers:  Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries.  Have you tried it?
comeau@comeaucomputing.com    http://www.comeaucomputing.com

Второй ответ (по прошествии некоторого времени):

From: support@comeaucomputing.com
To: Grigory Zubankov <Grigory.Zubankov@>)
Subject: comeau error
-----------------------------------------
We believe that the original wording in C++03 is confusing and needs 
fixing.  We're looking up whether alternative wording is 
satisfactory, as well as the intent.  Will get back to you again shortly.

-------
Comeau C/C++ 4.3.3:  Now in our 20th year!
Comeau C/C++ ONLINE ==>  http://www.comeaucomputing.com/tryitout
World Class Compilers:  Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries.  Have you tried it?
comeau@comeaucomputing.com    http://www.comeaucomputing.com

Непонятно что так «сбило с толку» разработчиков Comeau. Неоднозначности в 3.4.2/2 я не заметил, gcc 4.1.0 и vs 2005 компилируют пример без ошибок.


Любой из материалов, опубликованных на этом сервере, не может быть воспроизведен в какой бы то ни было форме и какими бы то ни было средствами без письменного разрешения владельцев авторских прав.