public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc warnings
@ 2008-08-12 15:36 kamelopardus
  2008-08-12 15:48 ` Andrew Bell
  0 siblings, 1 reply; 13+ messages in thread
From: kamelopardus @ 2008-08-12 15:36 UTC (permalink / raw)
  To: gcc-help


Hello.

I use gcc 3.4.2 under mingw32. I need to put compiler warnings about
uninitialized variables into some text file, for example, "warnings.txt".

i try 

gcc -O -Wuninitialized -v echo.c>warnings.txt

after the execution i can see warnings on the screen, but file
"warnings.txt" is empty.

Can anyone advise, where am i wrong?



-- 
View this message in context: http://www.nabble.com/gcc-warnings-tp18946614p18946614.html
Sent from the gcc - Help mailing list archive at Nabble.com.

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

* Re: gcc warnings
  2008-08-12 15:36 gcc warnings kamelopardus
@ 2008-08-12 15:48 ` Andrew Bell
  2008-08-12 15:52   ` Joel Dice
  2008-08-12 17:19   ` kamelopardus
  0 siblings, 2 replies; 13+ messages in thread
From: Andrew Bell @ 2008-08-12 15:48 UTC (permalink / raw)
  To: kamelopardus; +Cc: gcc-help

On Tue, Aug 12, 2008 at 10:25 AM, kamelopardus <killorn@yandex.ru> wrote:
>
> Hello.
>
> I use gcc 3.4.2 under mingw32. I need to put compiler warnings about
> uninitialized variables into some text file, for example, "warnings.txt".
>
> i try
>
> gcc -O -Wuninitialized -v echo.c>warnings.txt

They are going to stderr, not stdout.  Try:

gcc -O -Wuninitialized -v echo.c 2>& > warnings.txt

-- 
Andrew Bell
andrew.bell.ia@gmail.com

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

* Re: gcc warnings
  2008-08-12 15:48 ` Andrew Bell
@ 2008-08-12 15:52   ` Joel Dice
  2008-08-12 17:19   ` kamelopardus
  1 sibling, 0 replies; 13+ messages in thread
From: Joel Dice @ 2008-08-12 15:52 UTC (permalink / raw)
  To: Andrew Bell; +Cc: kamelopardus, gcc-help

On Tue, 12 Aug 2008, Andrew Bell wrote:

> On Tue, Aug 12, 2008 at 10:25 AM, kamelopardus <killorn@yandex.ru> wrote:
>>
>> Hello.
>>
>> I use gcc 3.4.2 under mingw32. I need to put compiler warnings about
>> uninitialized variables into some text file, for example, "warnings.txt".
>>
>> i try
>>
>> gcc -O -Wuninitialized -v echo.c>warnings.txt
>
> They are going to stderr, not stdout.  Try:
>
> gcc -O -Wuninitialized -v echo.c 2>& > warnings.txt

I think you mean:

gcc -O -Wuninitialized -v echo.c > warnings.txt 2>&1

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

* Re: gcc warnings
  2008-08-12 15:48 ` Andrew Bell
  2008-08-12 15:52   ` Joel Dice
@ 2008-08-12 17:19   ` kamelopardus
  1 sibling, 0 replies; 13+ messages in thread
From: kamelopardus @ 2008-08-12 17:19 UTC (permalink / raw)
  To: gcc-help




Andrew Bell wrote:
> 
> On Tue, Aug 12, 2008 at 10:25 AM, kamelopardus <killorn@yandex.ru> wrote:
>>
>> Hello.
>>
>> I use gcc 3.4.2 under mingw32. I need to put compiler warnings about
>> uninitialized variables into some text file, for example, "warnings.txt".
>>
>> i try
>>
>> gcc -O -Wuninitialized -v echo.c>warnings.txt
> 
> They are going to stderr, not stdout.  Try:
> 
> gcc -O -Wuninitialized -v echo.c 2>& > warnings.txt
> 
> -- 
> Andrew Bell
> andrew.bell.ia@gmail.com
> 
> 


It worked, thanks.
-- 
View this message in context: http://www.nabble.com/gcc-warnings-tp18946614p18947130.html
Sent from the gcc - Help mailing list archive at Nabble.com.

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

* RE: gcc warnings
  2007-10-17 14:28   ` Humpolicek, Jiri - Acision
@ 2007-10-17 15:25     ` Andrew Haley
  0 siblings, 0 replies; 13+ messages in thread
From: Andrew Haley @ 2007-10-17 15:25 UTC (permalink / raw)
  To: Humpolicek, Jiri - Acision; +Cc: Tim Prince, gcc-help

Humpolicek, Jiri - Acision writes:

 > This e-mail and any attachment is for authorised use by the
 > intended recipient(s) only. This email contains confidential
 > information. It should not be copied, disclosed to, retained or
 > used by, any party other than the intended recipient. Any
 > unauthorised distribution, dissemination or copying of this E-mail
 > or its attachments, and/or any use of any information contained in
 > them, is strictly prohibited and may be illegal. If you are not an
 > intended recipient then please promptly delete this e-mail and any
 > attachment and all copies and inform the sender directly via
 > email. Any emails that you send to us may be monitored by systems
 > or persons other than the named communicant for the purposes of
 > ascertaining whether the communication complies with the law and
 > company policies.

Quoting Ian Taylor,

Please do not include this sort of disclaimer in messages sent to
mailing lists hosted at gcc.gnu.org.  They are against list policy as
described at http://gcc.gnu.org/lists.html.  If you can't remove the
disclaimers from your outgoing e-mail messages, I suggest using a free
web-based e-mail account.  Thanks.

Everyone else:

Please do not reply to mails with disclaimers.

Andrew.

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

* RE: gcc warnings
  2007-10-17 13:28 ` Tim Prince
@ 2007-10-17 14:28   ` Humpolicek, Jiri - Acision
  2007-10-17 15:25     ` Andrew Haley
  0 siblings, 1 reply; 13+ messages in thread
From: Humpolicek, Jiri - Acision @ 2007-10-17 14:28 UTC (permalink / raw)
  To: Tim Prince; +Cc: gcc-help

>>             I have, from my point of view, strange problem. I want to
>tell gcc to report all compilation warnings, especially warnings about
>assigment from variable of greater type to variable with smaller type.
For >example, when I write following code and compile it with next
command no >warning is reported:
>> 
>> c++ -o test test.cpp -Wall -Wextra -Wconversion -pedantic
>> 
>You don't say anything about what problem you encounter, or what
>platform you use.  Your source code doesn't look like a suitable
>replacement for a test command which may be implemented in your shell,
>so it would be simpler to choose a non-conflicting name.

I don't understand you. My problem is, that I am not able to force gcc
to report warnings when I assign bigger type to smaller type. So I
decided to ask someone to help me or give me any explanations of this
behaviour.

Jiri Humpolicek


This e-mail and any attachment is for authorised use by the intended recipient(s) only. This email contains confidential information. It should not be copied, disclosed to, retained or used by, any party other than the intended recipient. Any unauthorised distribution, dissemination or copying of this E-mail or its attachments, and/or any use of any information contained in them, is strictly prohibited and may be illegal. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender directly via email. Any emails that you send to us may be monitored by systems or persons other than the named communicant for the purposes of ascertaining whether the communication complies with the law and company policies.

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

* RE: gcc warnings
  2007-10-17 11:49 ` Tom St Denis
@ 2007-10-17 14:08   ` Humpolicek, Jiri - Acision
  0 siblings, 0 replies; 13+ messages in thread
From: Humpolicek, Jiri - Acision @ 2007-10-17 14:08 UTC (permalink / raw)
  To: Tom St Denis; +Cc: gcc-help

>My recommendation is to simply not assign across types unless you have 
>to.  If you have a function like
>
>void myfunc(unsigned long somevalue)
>{
>}
>
>Then never store somevalue in anything but an unsigned long unless 
>you're sure of what you are doing.  Why would you write
>
>char careless = somevalue;
>
>just for the hell of it? 
>
>Tom

I fully understand with you Tom. I don't want to write this 'correct'
code, but problem is that it is easy to make this constructs
inadvertently. And IMHO this is place for compiler to report warning
'Here you overlook something'.

Because there is no reason do these things I think that warning is good
solution. And if someone want to use these language properties without
warning, it may be possible to use explicit cast to smaller type to
suppress warning (that is correct because there is evidence that user
knows about his doing).

Thanks, Jiri Humpolicek


This e-mail and any attachment is for authorised use by the intended recipient(s) only. This email contains confidential information. It should not be copied, disclosed to, retained or used by, any party other than the intended recipient. Any unauthorised distribution, dissemination or copying of this E-mail or its attachments, and/or any use of any information contained in them, is strictly prohibited and may be illegal. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender directly via email. Any emails that you send to us may be monitored by systems or persons other than the named communicant for the purposes of ascertaining whether the communication complies with the law and company policies.

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

* Re: gcc warnings
  2007-10-17  9:08 Humpolicek, Jiri - Acision
  2007-10-17 11:48 ` John Love-Jensen
  2007-10-17 11:49 ` Tom St Denis
@ 2007-10-17 13:28 ` Tim Prince
  2007-10-17 14:28   ` Humpolicek, Jiri - Acision
  2 siblings, 1 reply; 13+ messages in thread
From: Tim Prince @ 2007-10-17 13:28 UTC (permalink / raw)
  To: Humpolicek, Jiri - Acision; +Cc: gcc-help

Humpolicek, Jiri - Acision wrote:

>             I have, from my point of view, strange problem. I want to tell gcc to report all compilation warnings, especially warnings about assigment from variable of greater type to variable with smaller type. For example, when I write following code and compile it with next command no warning is reported:
> 
> c++ -o test test.cpp -Wall -Wextra -Wconversion -pedantic
> 
You don't say anything about what problem you encounter, or what
platform you use.  Your source code doesn't look like a suitable
replacement for a test command which may be implemented in your shell,
so it would be simpler to choose a non-conflicting name.

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

* Re: gcc warnings
  2007-10-17  9:08 Humpolicek, Jiri - Acision
  2007-10-17 11:48 ` John Love-Jensen
@ 2007-10-17 11:49 ` Tom St Denis
  2007-10-17 14:08   ` Humpolicek, Jiri - Acision
  2007-10-17 13:28 ` Tim Prince
  2 siblings, 1 reply; 13+ messages in thread
From: Tom St Denis @ 2007-10-17 11:49 UTC (permalink / raw)
  To: Humpolicek, Jiri - Acision; +Cc: gcc-help

Humpolicek, Jiri - Acision wrote:
> Hi,
>             I have, from my point of view, strange problem. I want to tell gcc to report all compilation warnings, especially warnings about assigment from variable of greater type to variable with smaller type. For example, when I write following code and compile it with next command no warning is reported:
>
> c++ -o test test.cpp -Wall -Wextra -Wconversion -pedantic
>
> #include "stdio.h"
>
> int main()
> {
>         long a = 10000;
>         unsigned char b = a;
>
>         printf("%d\n", b);
>
>         return b;
> }
>
>   

The problem is that's not an error or problem as far as the C standard 
[and C++] goes.  So a warning for that while valid, would probably be 
out of line.

My recommendation is to simply not assign across types unless you have 
to.  If you have a function like

void myfunc(unsigned long somevalue)
{
}

Then never store somevalue in anything but an unsigned long unless 
you're sure of what you are doing.  Why would you write

char careless = somevalue;

just for the hell of it? 

Tom


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

* Re: gcc warnings
  2007-10-17  9:08 Humpolicek, Jiri - Acision
@ 2007-10-17 11:48 ` John Love-Jensen
  2007-10-17 11:49 ` Tom St Denis
  2007-10-17 13:28 ` Tim Prince
  2 siblings, 0 replies; 13+ messages in thread
From: John Love-Jensen @ 2007-10-17 11:48 UTC (permalink / raw)
  To: Humpolicek, Jiri - Acision, MSX to GCC

Hi Jiri,

It's valid C code to assign from a variable of greater type to one of
smaller type.

I think that this is very unfortunate.  I presume you do as well.  Alas.

You can act upon it programmatically, in runtime, if you do something like:

#include "stdio.h"

unsigned char LongAsUnsignedChar(long c)
{
  if(c > 255 || c < 0)
  {
    fprintf(stderr, "Error: %ld outside of 0,255 range\n", c);
  }

  return c;
}

int main()
{
  long a = 10000;
  unsigned char b = LongAsUnsignedChar(a);

  printf("%d\n", b);

  return b;
}

Alternatively, you can use a B&D language like Ada where such assignments
cannot happen silently and need explicit conversion.

HTH,
--Eljay

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

* gcc warnings
@ 2007-10-17  9:08 Humpolicek, Jiri - Acision
  2007-10-17 11:48 ` John Love-Jensen
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Humpolicek, Jiri - Acision @ 2007-10-17  9:08 UTC (permalink / raw)
  To: gcc-help

Hi,
            I have, from my point of view, strange problem. I want to tell gcc to report all compilation warnings, especially warnings about assigment from variable of greater type to variable with smaller type. For example, when I write following code and compile it with next command no warning is reported:

c++ -o test test.cpp -Wall -Wextra -Wconversion -pedantic

#include "stdio.h"

int main()
{
        long a = 10000;
        unsigned char b = a;

        printf("%d\n", b);

        return b;
}

Gcc -v prints these information, but I have already test it on different versions but with same unsatsfactory results:

Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.1.2/work/gcc-4.1.2/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.1.2 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.2 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.2/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.2/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --disable-libunwind-exceptions --disable-multilib --enable-libmudflap --disable-libssp --enable-java-awt=gtk --enable-objc-gc --enable-languages=c,c++,java,objc,obj-c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
Thread model: posix
gcc version 4.1.2 (Gentoo 4.1.2)

Where is the problem?

Thanks for explanations and have a nice day, Jiri Humpolicek



This e-mail and any attachment is for authorised use by the intended recipient(s) only. This email contains confidential information. It should not be copied, disclosed to, retained or used by, any party other than the intended recipient. Any unauthorised distribution, dissemination or copying of this E-mail or its attachments, and/or any use of any information contained in them, is strictly prohibited and may be illegal. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender directly via email. Any emails that you send to us may be monitored by systems or persons other than the named communicant for the purposes of ascertaining whether the communication complies with the law and company policies.

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

* Re: gcc warnings
  2000-05-24 14:29 Zia Babar
@ 2000-05-24 23:48 ` Martin v. Loewis
  0 siblings, 0 replies; 13+ messages in thread
From: Martin v. Loewis @ 2000-05-24 23:48 UTC (permalink / raw)
  To: zbabar; +Cc: gcc-help

> I need some resource on the warnings and errors that gcc generates and I
> wonder if there is some literature available listing all the warnings and
> their probable causes. Actually I've been asked to debug some C project
> files and since I'm a newbie to C therefore most of the warnings generated
> by gcc during compilation escape me.

Please have a look at the section "Warning Options" in the gcc manual.

Regards,
Martin

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

* gcc warnings
@ 2000-05-24 14:29 Zia Babar
  2000-05-24 23:48 ` Martin v. Loewis
  0 siblings, 1 reply; 13+ messages in thread
From: Zia Babar @ 2000-05-24 14:29 UTC (permalink / raw)
  To: 'gcc-help@gcc.gnu.org'

Title: gcc warnings





Hi,


I need some resource on the warnings and errors that gcc generates and I wonder if there is some literature available listing all the warnings and their probable causes. Actually I've been asked to debug some C project files and since I'm a newbie to C therefore most of the warnings generated by gcc during compilation escape me.

Thanks in advance.


Zia 




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

end of thread, other threads:[~2008-08-12 15:52 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-12 15:36 gcc warnings kamelopardus
2008-08-12 15:48 ` Andrew Bell
2008-08-12 15:52   ` Joel Dice
2008-08-12 17:19   ` kamelopardus
  -- strict thread matches above, loose matches on Subject: below --
2007-10-17  9:08 Humpolicek, Jiri - Acision
2007-10-17 11:48 ` John Love-Jensen
2007-10-17 11:49 ` Tom St Denis
2007-10-17 14:08   ` Humpolicek, Jiri - Acision
2007-10-17 13:28 ` Tim Prince
2007-10-17 14:28   ` Humpolicek, Jiri - Acision
2007-10-17 15:25     ` Andrew Haley
2000-05-24 14:29 Zia Babar
2000-05-24 23:48 ` Martin v. Loewis

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).