[Ruby 1.9-Bug#4120][Assigned] 2 failures on test/mkmf/test_convertible.rb

Bug #4120: 2 failures on test/mkmf/test_convertible.rb
http://redmine.ruby-lang.org/issues/show/4120

起票者: Usaku NAKAMURA
ステータス: Assigned, 優先度: Normal
担当者: Nobuyoshi N., カテゴリ: lib, Target version: 1.9.x
ruby -v: ruby 1.9.3dev (2010-12-06 trunk 30090) [x64-mswin64_100]

表題のテストで、以下の2件の失敗が出ています。
なんかよくわからんので報告のみ。

  1. Failure:
    test_typeof_builtin(TestMkmf::TestConvertible)
    [C:/Users/usa/ruby/test/mkmf/test_convertible.rb:8]:
    <“long”> expected but was
    <“int”>.

  2. Failure:
    test_typeof_typedef(TestMkmf::TestConvertible)
    [C:/Users/usa/ruby/test/mkmf/test_convertible.rb:21]:
    <“long”> expected but was
    <“int”>.

なかだです。

At Mon, 6 Dec 2010 11:11:12 +0900,
Usaku NAKAMURA wrote in [ruby-dev:42684]:

  1. Failure:
    test_typeof_builtin(TestMkmf::TestConvertible)
    [C:/Users/usa/ruby/test/mkmf/test_convertible.rb:8]:
    <“long”> expected but was
    <“int”>.

  2. Failure:
    test_typeof_typedef(TestMkmf::TestConvertible)
    [C:/Users/usa/ruby/test/mkmf/test_convertible.rb:21]:
    <“long”> expected but was
    <“int”>.

VCでは以下のコードがエラーにならずに警告しか出ないからなのですが、何を
考えているんでしょうね。

int foo();
long foo();

int bar(int);
int bar(long);

longじゃなくてintとshortならちゃんとエラーになります。

$B$3$s$K$A$O!"$J$+$`$i(B($B$&(B)$B$G$9!#(B

In message “[ruby-dev:42688] Re: [Ruby 1.9-Bug#4120][Assigned] 2
failures on test/mkmf/test_convertible.rb”
on Dec.06,2010 15:34:02, [email protected] wrote:

VC$B$G$O0J2<$N%3!<%I$,%(%i!<$K$J$i$:$K7Y9p$7$+=P$J$$$+$i$J$N$G$9$,!"2?$r(B
$B9M$($F$$$k$s$G$7$g$&$M!#(B

$B5,3J>e$3$l$r%(%i!<$K$7$J$$$H$$$1$J$$$H$$$&%k!<%k$O$J$$$h$&$J(B
$B5$$,$9$k$N$G(B[$BMW3NG’(B]$B!"IaDL$KF1$8I}$J$N$G7Y9p$G5v$7$F$d$m$&$H(B
$B$$$&$3$H$G$7$g$&$+$M$(!#(B

$B$J$N$G!“$@$H$7$?$i!”$3$l$,%(%i!<$K$J$k$3$H$rMxMQ$9$kE[$,0-$$(B
$B$H$$$&$3$H$K$J$k$s$8$c$J$$$G$7$g$&$+!#(B

$B$=$l$G$O!#(B

チケット #4120 が更新されました。 (by Nobuyoshi N.)

ステータス AssignedからClosedに変更
進捗 % 0から100に変更

This issue was solved with changeset r30107.
Usaku, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

2010年12月6日15:53 U.Nakamura [email protected]:

こんにちは、なかむら(う)です。

In message “[ruby-dev:42688] Re: [Ruby 1.9-Bug#4120][Assigned] 2 failures on
test/mkmf/test_convertible.rb”
on Dec.06,2010 15:34:02, [email protected] wrote:

VCでは以下のコードがエラーにならずに警告しか出ないからなのですが、何を
考えているんでしょうね。

規格上これをエラーにしないといけないというルールはないような
気がするので[要確認]、普通に同じ幅なので警告で許してやろうと
いうことでしょうかねえ。

最近はC言語の規格もインターネットで閲覧できるんですね。インターネット万歳

3.5 DECLARATIONS
(snip)
All declarations in the same scope that refer to the same object or
function shall specify compatible types.

compatible typesの定義をみると

6.2.7 Compatible type and composite type

Two types have compatible type if their types are the same. Additional
rules for
determining whether two types are compatible are described in 6.7.2
for type specifiers,
in 6.7.3 for type qualifiers, and in 6.7.5 for declarators.

なんか、基本厳密一致だけど詳細は type specifiersの章を見ろというのでみる

6.7.2 Type specifiers
Syntax
type-specifier:
void
char
short
int
long
float
double
signed
unsigned
_Bool
_Complex
struct-or-union-specifier ∗
enum-specifier
typedef-name

Constraints
(snip)
the type specifiers may occur in any order, possibly
intermixed with the other declaration specifiers.

順序とか気にしなくていいよ。だそうな
適当に斜め読みしただけなので見落としてるかも知れませんがgccが正しそうな雰囲気。
JIS X3010 (ようするにC89)も見ましたが、同じように見えます。

なので、だとしたら、これがエラーになることを利用する奴が悪い
ということになるんじゃないでしょうか。

とはいえ、VCを無視するのは現実的ではないのでテストケース側を直すことに賛成します。

$B$3$s$K$A$O!"$J$+$`$i(B($B$&(B)$B$G$9!#(B

In message “[ruby-dev:42694] Re: [Ruby 1.9-Bug#4120][Assigned] 2
failures on test/mkmf/test_convertible.rb”
on Dec.06,2010 21:09:36, [email protected] wrote:

VC$B$G$O0J2<$N%3!<%I$,%(%i!<$K$J$i$:$K7Y9p$7$+=P$J$$$+$i$J$N$G$9$,!"2?$r(B
$B9M$($F$$$k$s$G$7$g$&$M!#(B

$B5,3J>e$3$l$r%(%i!<$K$7$J$$$H$$$1$J$$$H$$$&%k!<%k$O$J$$$h$&$J(B
$B5$$,$9$k$N$G(B[$BMW3NG’(B]$B!"IaDL$KF1$8I}$J$N$G7Y9p$G5v$7$F$d$m$&$H(B
$B$$$&$3$H$G$7$g$&$+$M$(!#(B

$B:G6a$O(BC$B8@8l$N5,3J$b%$%s%?!<%M%C%H$G1\Mw$G$-$k$s$G$9$M!#%$%s%?!<%M%C%HK|:P(B

http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf

$B<B$O$=$N8e<+J,$G$b(BC99$BD/$a$F$?$s$G$9$,!“<B:]$KL7=b$,5/$-$?;~$I(B
$B$&$9$k$+$O(B Annex J.2 Undefined behavior $B$NJ}$K$”$j$^$9!#(B
$B$D$^$j!"(B

In a context requiring two function types to be compatible, they do
not have
compatible return types, or their parameters disagree in use of the
ellipsis terminator
or the number and type of parameters (after default argument
promotion, when there
is no parameter type list or when one type is specified by a function
definition with an
identifier list) (6.7.5.3).

$B$NItJ,$G$9!#(B
$B$H$$$&$o$1$G!"L$Dj5AF0:n$N%j%9%H$K$3$&$d$C$F5s$2$i$l$F$$$k$o(B
$B$1$J$N$G!"L7=b$9$kFs$D$N4X?t@k8@;R$,B8:_$9$k%3!<%I$,$I$N$h$&(B
$B$K07$o$l$k$+$OL$Dj5A$G$9!#I!$+$i0-Kb!#(B

$B$J$N$G!“$@$H$7$?$i!”$3$l$,%(%i!<$K$J$k$3$H$rMxMQ$9$kE[$,0-$$(B
$B$H$$$&$3$H$K$J$k$s$8$c$J$$$G$7$g$&$+!#(B

$B$H$$$&$o$1$G!"0-$$$I$3$m$8$c$J$/$F!"1’Ch$,LG$V$+$b$7$l$J$$%3(B
$B!<%I$r=q$$$F$=$l$r=hM}7O$K?)$o$;$k$J$s$F?.$8$i$l$J$$(B!

$B$H$O$$$(!"(BVC$B$rL5;k$9$k$N$O8=<BE*$G$O$J$$$N$G%F%9%H%1!<%9B&$rD>$9$3$H$K;?@.$7$^$9!#(B

$B$^$“!”$=$&4JC1$K(BC$B=hM}7O$,1’Ch$rLG$$7$?$j$O$7$J$$$H;W$&$N$G!“(B
$B<B:]$K8=>u(Bruby$B$,%5%]!<%H$7$F$k=hM}7O$4$H$K$I$&$J$k$N$+>pJs$r(B
$B=8$a$FBP1~$9$k$7$+$J$$$+$J$H;W$$$^$9!#(B
$B$5$9$,$K%(%i!<$b=P$5$J$-$c7Y9p$9$i$7$J$$!”$H$$$&=hM}7O$O$J$$(B
$B$H?.$8$?$$$N$G!"7Y9p$+$b$7$l$J$$$H$$$&$3$H$r2!$5$($5$($9$l$P(B
$BBg>fIW$8$c$J$$$G$9$+$M!#(B

$B$=$l$G$O!#(B