public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/19539] New: missing operand: 90.0 * -Sin(A)
@ 2005-01-20  3:30 dave at synergy dot org
  2005-01-20  6:25 ` [Bug ada/19539] missing operand: B * -A pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: dave at synergy dot org @ 2005-01-20  3:30 UTC (permalink / raw)
  To: gcc-bugs

As the repro included shows:

    A := 90.0;
    B := 30.0 * -Sin(A);

fails with a missing operand compile-time error, but:

    A := 90.0;
    B := -Sin(A);
    B := 30 * B;

works.

with Ada.Numerics.Elementary_Functions;
use Ada.Numerics.Elementary_Functions;

procedure X is

  A : float;
  B : float;

begin
  A := 90.0;
  -- This works.
  B := -Sin(A);
  B := B * 30.0;
  -- This produces a compile-time error: x.adb:15:14: missing operand
  B := 30.0 * -Sin(A);
end;

-- 
           Summary: missing operand: 90.0 * -Sin(A)
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ada
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dave at synergy dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i586-suse-linux
  GCC host triplet: i586-suse-linux
GCC target triplet: i586-suse-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19539


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug ada/19539] missing operand: B * -A
  2005-01-20  3:30 [Bug ada/19539] New: missing operand: 90.0 * -Sin(A) dave at synergy dot org
@ 2005-01-20  6:25 ` pinskia at gcc dot gnu dot org
  2005-01-21  2:05 ` chrisp_42 at bigpond dot com
  2005-01-21  2:10 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-20  6:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-20 06:25 -------
Hmm, is *- special operand in Ada or is this just a parse error in the front-end (I don't know Ada that at 
all, well I know enough to be able to read it a little).
But you can reproduce it with the following also with out the use of a function:
procedure X is
  B : float;
begin
  B := 90.0;
  B := B*-B;
end;


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|missing operand: 90.0 * -   |missing operand: B * -A
                   |Sin(A)                      |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19539


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug ada/19539] missing operand: B * -A
  2005-01-20  3:30 [Bug ada/19539] New: missing operand: 90.0 * -Sin(A) dave at synergy dot org
  2005-01-20  6:25 ` [Bug ada/19539] missing operand: B * -A pinskia at gcc dot gnu dot org
@ 2005-01-21  2:05 ` chrisp_42 at bigpond dot com
  2005-01-21  2:10 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: chrisp_42 at bigpond dot com @ 2005-01-21  2:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From chrisp_42 at bigpond dot com  2005-01-21 02:04 -------
(In reply to comment #1)
> Hmm, is *- special operand in Ada or is this just a parse error in the
front-end (I don't know Ada that at 

You are actually fairly close.  *- is not a special operator, but the multiply
operator has a higher precedence than the unary minus.  This causes the multiply
to bind to the minus sign (not the result of the unary minus).

The fix is the write the code as follows:
  B := B*(-B);

This is actually fairly common in Ada.

This TR is invalid because the test case is invalid Ada code.
Whether or not the error message could be improved or not I dont know, but most
Ada programmers would immediately know what is wrong with the code.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19539


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug ada/19539] missing operand: B * -A
  2005-01-20  3:30 [Bug ada/19539] New: missing operand: 90.0 * -Sin(A) dave at synergy dot org
  2005-01-20  6:25 ` [Bug ada/19539] missing operand: B * -A pinskia at gcc dot gnu dot org
  2005-01-21  2:05 ` chrisp_42 at bigpond dot com
@ 2005-01-21  2:10 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-21  2:10 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-21 02:10 -------
(In reply to comment #2)
> (In reply to comment #1)
> > Hmm, is *- special operand in Ada or is this just a parse error in the
> front-end (I don't know Ada that at 
> 
> You are actually fairly close.  *- is not a special operator, but the multiply
> operator has a higher precedence than the unary minus.  This causes the multiply
> to bind to the minus sign (not the result of the unary minus).

Oh, thanks (I learned more about Ada than I knew before, I will remember about in the future).

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19539


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-01-21  2:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-20  3:30 [Bug ada/19539] New: missing operand: 90.0 * -Sin(A) dave at synergy dot org
2005-01-20  6:25 ` [Bug ada/19539] missing operand: B * -A pinskia at gcc dot gnu dot org
2005-01-21  2:05 ` chrisp_42 at bigpond dot com
2005-01-21  2:10 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).