www.delorie.com/djgpp/bugs/show.cgi   search  
Bug 000333

When Created: 12/16/2000 15:16:00
Against DJGPP version: 2.01
By whom: defcon1@free.fr
Abstract: DJGPP resfuse multiplication
Hi!

I got a program which is supposed to fill SRC with 5 "ABCDEFGHIJ" in a row. Then the program is gonna pick 1 letter from SRC every ten letters and put
it in DEST, thus DEST would be filled with "AAAAA".
Unfortunately, although it's working under Turbo C++, DJGPP refuse to compile
apparently because of a multiplication at the line: "src[i*10]";

Here's my source code:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

void main()
{
int i;
char *src = (char *)malloc(100);
char *dest = (char *)malloc(20);

strcpy(src,"ABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJ");

for (i=0; i<5; i++) dest[i] = src[i*10]; /* ERROR */

dest[5]=0;

printf("\r\nSrc says: %s \r\nDest says: %s\n", src, dest);

free(src);
free(dest);
}

Note added: 12/20/2000 07:59:24
By whom: eliz@is.elta.co.il
This is not reproducible.  I'm sure it's some kind of cockpit error.

I'm clisong this report.

Closed on 12/20/2000 08:00:22: Not reproducible
By whom: eliz@is.elta.co.il

Note added: 12/24/2000 08:50:22
By whom: defcon1@free.fr
First, i'm french so excuse my english.
I think i found the solution:
DJGPP refuses to multiply a variable with by number.

DJGPP refuses to compile this:

int a,b;
a=b*20;

but it accepts:

int a,b,c;
c=20;
a=b*c;

Maybe a didn't check an option which allows me to do that.
I don't know.

Bye!
Franck Bauquier
http://defcon1.free.fr

Note added: 12/31/2000 02:46:16
By whom: eliz@is.elta.co.il
I still cannot reproduce this.



  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2010   by DJ Delorie     Updated Jul 2010