From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e01fe1b326df26d4 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!news-feed01.roc.ny.frontiernet.net!nntp.frontiernet.net!newsfeed2.easynews.com!newsfeed1.easynews.com!easynews.com!easynews!news-west.rr.com!news.rr.com!news-server.columbus.rr.com!cyclone2.kc.rr.com!news2.kc.rr.com!tornado.socal.rr.com.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Division by zero References: <79ahr0jozmqb$.10jzllrcjpmsv.dlg@40tude.net> From: Keith Thompson Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) Cancel-Lock: sha1:gGipMlvKksojwZxJFf0H7TY4I8g= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 14 Jun 2005 08:35:26 GMT NNTP-Posting-Host: 66.75.136.120 X-Complaints-To: abuse@rr.com X-Trace: tornado.socal.rr.com 1118738126 66.75.136.120 (Tue, 14 Jun 2005 01:35:26 PDT) NNTP-Posting-Date: Tue, 14 Jun 2005 01:35:26 PDT Organization: Road Runner High Speed Online http://www.rr.com Xref: g2news1.google.com comp.lang.ada:11337 Date: 2005-06-14T08:35:26+00:00 List-Id: Jeffrey Carter writes: [...] > I suppose a compiler could tell if "/" had been redefined for a type, > and produce warnings only in the case where it had not, but I don't > know of any compilers that do. I do: % gcc --version gcc (GCC) 4.0.0 Copyright (C) 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. % cat -n foo.adb 1 procedure Foo is 2 X : Integer := 1; 3 Y : Integer := 1; 4 begin 5 declare 6 function "/"(Left, Right: Integer) return Integer is 7 begin 8 return Right; 9 end "/"; 10 begin 11 X := X / 0; 12 X := 1 / 0; 13 end; 14 Y := Y / 0; 15 Y := 1 / 0; 16 end Foo; % gcc -c foo.adb foo.adb:14:14: warning: division by zero foo.adb:14:14: warning: "Constraint_Error" will be raised at run time foo.adb:15:12: division by zero foo.adb:15:12: static expression raises "Constraint_Error" I'd be surprised if this weren't the case. By the time the compiler is deciding whether to issue a warning, it knows that the "/" being invoked is a user-defined operator rather than a predefined operator (and probably doesn't care that its name is "/"). If a compiler issued a warning on a call to a user-defined "/" function with a second parameter of 0, I'd consider it a bug (unless it was a result of an analysis of the actual function). -- Keith Thompson (The_Other_Keith) kst-u@mib.org San Diego Supercomputer Center <*> We must do something. This is something. Therefore, we must do this.