On Wed, 23 Feb 2022 at 07:39, Krishna Narayanan < krishnanarayanan132002@xxxxxxxxx> wrote: > > > On Tue, Feb 22, 2022 at 9:44 PM Jonathan Wakely <jwakely.gcc@xxxxxxxxx> > wrote: > >> On Tue, 22 Feb 2022 at 15:38, Krishna Narayanan wrote: >> >>> Yes, it does. >>> I used dg-warning and not dg warning (that was a sheer typing mistake). >>> The warning is about the uninitialized variable being used in the >>> testcase yet there is no warning on that line and the test results in >>> FAIL. >>> I used /* { dg-warning "uninitialized" } */ on that particular line.I >>> used the test in gcc.dg, with other directive /* { dg-options "-O2" } >>> */ . >>> Can you help me where I went wrong? >>> >> >> Don't you need -Wuninitialized in the dg-options as well? >> > > Yes I tried it with /* { dg-options "-O2 -Wuninitialized" } */ but still it FAILs. Yes, but it fails differently now. You need to read the output more carefully. Look at the gcc.log file, which shows you the full output. When you enable warnings there are TWO warnings printed. You are only testing for one. You can also compile the test by hand using the same options. What happens? You get TWO warnings. You only tested for one. So it's going to FAIL. The log file should show something like this: PASS: test.c (test for warnings, line 10) FAIL: test.c (test for excess errors) Excess errors: test.c:6: warning: 'a' may be used uninitialized [-Wmaybe-uninitialized] That means it matched the dg-warning on line 10, but there was also another warning on line 6, which dejagnu thinks was unexpected (because you didn't tell it to expect it or to ignore it). That makes the test fail.